#include <bits/stdc++.h>
using namespace std;
#define ms(s,n) memset(s,n,sizeof(s))
#define all(a) a.begin(),a.end()
#define present(t, x) (t.find(x) != t.end())
#define sz(a) int((a).size())
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); --i)
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9+7;
const int INF = (int) 1e9+1;
inline ll gcd(ll a,ll b){ll r;while(b){r=a%b;a=b;b=r;}return a;}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
bool cmp(pi a, pi b){
if(abs(a.fi) != abs(b.fi))
return abs(a.fi) < abs(b.fi);
return a.se < b.se;
}
#define endl "\n"
void TC(){
int n; cin >> n;
vii a(n);
for(int i = 0; i < n; i++){
int x; cin >> x;
a[i].first = x;
a[i].se = i;
}
sort(all(a), cmp);
ll res, sum = INT_MAX;
int idx;
for(int i = 1; i < n; i++){
int tmp = abs(a[i].fi + a[i-1].fi);
if(tmp < sum){
sum = tmp;
res = a[i].fi + a[i-1].fi;
idx = min(a[i].se, a[i-1].se);
}
else if(tmp==sum){
if(idx > min(a[i].se, a[i-1].se)){
res = a[i].fi + a[i-1].fi;
idx = min(a[i].se, a[i-1].se);
}
}
}
cout << res << endl;
}
int main(){
//freopen("input.txt","r", stdin);
//freopen("output.txt","w",stdout);
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t; cin >> t;
while(t--){
TC();
}
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiAKI2RlZmluZSBtcyhzLG4pIG1lbXNldChzLG4sc2l6ZW9mKHMpKQojZGVmaW5lIGFsbChhKSBhLmJlZ2luKCksYS5lbmQoKQojZGVmaW5lIHByZXNlbnQodCwgeCkgKHQuZmluZCh4K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