#include <iostream>
using namespace std;

int main() {
    int t; cin >> t;
    while (t--) {
        int n, a[100]; cin >> n;
        for (int i = 0; i < n; i++) cin >> a[i];

        int ans = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                int x = a[i], y = a[j];
                if (x == y) {
                    if (x + 1 > ans) ans = x + 1;
                } else {
                    int d = abs(x - y);
                    for (int k = 1; k <= d; k++) {
                        if (d % k == 0) {
                            int x1 = x + (k - x % k) % k;
                            int y1 = y + (k - y % k) % k;
                            int a1 = x1, b1 = y1;
                            while (b1) {
                                int temp = b1;
                                b1 = a1 % b1;
                                a1 = temp;
                            }
                            if (a1 > ans) ans = a1;
                        }
                    }
                }
            }
        }
        cout << ans << "\n";
    }
    return 0;
}
