#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t, n, x, i, j;
  cin >> t;
  while (t--) {
    cin >> n;
    vector<int> p, q;
    long long s = LONG_LONG_MIN;
    for (i = 0; i < n; i++) {
      cin >> x;
      if (x >= 0)
        p.push_back(x);
      else
        q.push_back(x);
    }
    int ps, ns, mn;
    ps = p.size();
    ns = q.size();
    mn = min(ps, ns);
    sort(p.begin(), p.end(), greater<int>());
    sort(q.begin(), q.end(), greater<int>());
    if (ps == 0) {
      s = q[0];
      cout << s << endl;
      continue;
    }
    if (ns == 0) {
      s = p[0];
      cout << s << endl;
      continue;
    }
    if (ps > 0 && ns > 0) {
      for (i = 0; i < mn; i++) {
        long long t = p[i] + q[i];
        if (t > s)
          s = t;
        else
          break;
      }
      cout << s << endl;
    }
  }
  return 0;
}
