#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int t;
    cin >> t;
    
    while (t--) {
        int n;
        cin >> n;
        vector<int> a(n);
        for (int &x : a) cin >> x;

        int res = 1;
        
        // Try all pairs and compute GCD
        for (int i = 0; i < n; ++i) {
            for (int j = i + 1; j < n; ++j) {
                int g = __gcd(a[i], a[j]);
                
                // Count frequencies of numbers modulo gcd
                unordered_map<int, int> freq;
                for (int x : a) freq[x % g]++;
                
                // Find maximum frequency of same remainders
                for (auto p : freq) {
                    if (p.second > 1) {
                        res = max(res, g);
                    }
                }
            }
        }
        
        cout << res << endl;
    }
    
    return 0;
}
