#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using ld = long double; template <typename T> int sz(T &x) { return (int)(x.size()); } int power(int x, int y, int mod) { if (y == 0) { return 1; } int z = power(x, y >> 1, mod); z = z * 1ll * z % mod; if (y & 1) { z = z * 1ll * x % mod; } return z; } const int mod = 998244353; const int inf = 1000000007; const ll linf = inf * 1ll * inf * 8; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); void solve() { int n; cin >> n; vector<ll> a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } int cntZero = 0; for (int step = 1; step < n; ++step) { sort(a.begin(), a.end()); vector<ll> b; if (cntZero > 0) { cntZero--; b.push_back(a[0]); } for (int i = 1; i < sz(a); ++i) { if (a[i] == a[i - 1]) { cntZero++; } else { b.push_back(a[i] - a[i - 1]); } } a = b; } if (cntZero) { cout << "0\n"; } else { cout << a[0] << "\n"; } } int main() { #ifndef LOCAL58 ios_base :: sync_with_stdio(false); cin.tie(nullptr); #endif int t = 1; cin >> t; while (t--) { solve(); } return 0; }