#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> arr(n, 0);
    for (auto &i : arr) cin >> i;
    sort(arr.begin(), arr.end());
    int pos = count_if(arr.begin(), arr.end(), [](int x) {
      if (x > 0)
        return true;
      else
        return false;
    });
    int neg = count_if(arr.begin(), arr.end(), [](int x) {
      if (x < 0)
        return true;
      else
        return false;
    });
    int rds = (neg < pos) ? neg : pos;
    if (rds == 0) {
      cout << arr[n - 1] << endl;
    } else if (neg == pos) {
      int x = 0;
      for (auto i : arr) x += i;
      cout << x << endl;
    } else {
      long long int sum = 0;
      for (int i = neg - 1; i > neg - 1 - rds; i--) {
        sum += arr[i];
      }
      for (int i = n - 1; i > n - 1 - rds; i--) {
        sum += arr[i];
      }
      cout << sum << endl;
    }
  }
  return 0;
}
