// #include "bits/stdc++.h"
// #pragma GCC optimize("Ofast,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
// using namespace std;
// using ll = long long int;
// mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
// struct input_checker {
// string buffer;
// int pos;
// const string all = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
// const string number = "0123456789";
// const string upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
// const string lower = "abcdefghijklmnopqrstuvwxyz";
// input_checker() {
// pos = 0;
// while (true) {
// int c = cin.get();
// if (c == -1) {
// break;
// }
// buffer.push_back((char) c);
// }
// }
// int nextDelimiter() {
// int now = pos;
// while (now < (int) buffer.size() && buffer[now] != ' ' && buffer[now] != '\n') {
// now++;
// }
// return now;
// }
// string readOne() {
// assert(pos < (int) buffer.size());
// int nxt = nextDelimiter();
// string res;
// while (pos < nxt) {
// res += buffer[pos];
// pos++;
// }
// // cerr << res << endl;
// return res;
// }
// string readString(int minl, int maxl, const string &pattern = "") {
// assert(minl <= maxl);
// string res = readOne();
// assert(minl <= (int) res.size());
// assert((int) res.size() <= maxl);
// for (int i = 0; i < (int) res.size(); i++) {
// assert(pattern.empty() || pattern.find(res[i]) != string::npos);
// }
// return res;
// }
// int readInt(int minv, int maxv) {
// assert(minv <= maxv);
// int res = stoi(readOne());
// assert(minv <= res);
// assert(res <= maxv);
// return res;
// }
// long long readLong(long long minv, long long maxv) {
// assert(minv <= maxv);
// long long res = stoll(readOne());
// assert(minv <= res);
// assert(res <= maxv);
// return res;
// }
// void readSpace() {
// assert((int) buffer.size() > pos);
// assert(buffer[pos] == ' ');
// pos++;
// }
// void readEoln() {
// assert((int) buffer.size() > pos);
// assert(buffer[pos] == '\n');
// pos++;
// }
// void readEof() {
// assert((int) buffer.size() == pos);
// }
// };
// int main()
// {
// ios::sync_with_stdio(false); cin.tie(0);
// vector<ll> v = {1};
// while (1) {
// v.push_back(1);
// for (int i = 0; i+1 < v.size(); ++i) v[i] += v[i+1];
// cout << v[0] << ' ';
// if (v[0] > 1e18) break;
// }
// int sz = v.size(), zero = 0, ops = 0;
// for (int i = 0; sz + zero > 1; ++i) {
// ++ops;
// if (sz == 0) {
// v[0] = 0;
// break;
// }
// if (sz == 1) break;
// sort(v.begin(), v.end());
// vector<ll> w;
// int ptr = 0, mn = v[0], flag = zero > 0;
// if (zero) --zero;
// for (int j = 0; j + 1 < sz; ++j) {
// if (v[j] == v[j+1]) ++zero;
// else w.push_back(v[j+1] - v[j]);
// }
// if (flag) w.push_back(mn);
// v = w;
// sz = v.size();
// }
// cout << ops << '\n';
// }
#include "bits/stdc++.h"
// #pragma GCC optimize("Ofast,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
using namespace std;
using ll = long long int;
mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int main()
{
ios::sync_with_stdio(false); cin.tie(0);
int t; cin >> t;
while (t--) {
int n; cin >> n;
vector<ll> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
for (int iter = 0; iter < min(100, n-1); ++iter) {
sort(begin(a), end(a));
for (int i = 0; i+1 < a.size(); ++i) a[i] = a[i+1] - a[i];
a.pop_back();
}
if (size(a) == 1) {
cout << a[0] << '\n';
continue;
}
int zeros = count(begin(a), end(a), 0);
sort(rbegin(a), rend(a));
while (!a.empty() and a.back() == 0) a.pop_back();
for (int iter = 100; iter < n-1; ++iter) {
if (zeros) {
a.push_back(0);
--zeros;
}
sort(begin(a), end(a));
for (int i = 0; i+1 < a.size(); ++i) a[i] = a[i+1] - a[i];
a.pop_back();
zeros += count(begin(a), end(a), 0);
sort(rbegin(a), rend(a));
while (!a.empty() and a.back() == 0) a.pop_back();
}
if (zeros) a = {0};
cout << a[0] << '\n';
}
}