#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 100;
const int M = 1e9 + 7;
long long mod(long long x) { return ((x % M + M) % M); }
long long add(long long a, long long b) { return mod(mod(a) + mod(b)); }
long long mul(long long a, long long b) { return mod(mod(a) * mod(b)); }
long long modPow(long long a, long long b) {
  if (b == 0) return 1LL;
  if (b == 1) return a % M;
  long long res = 1;
  while (b) {
    if (b % 2 == 1) res = mul(res, a);
    a = mul(a, a);
    b = b / 2;
  }
  return res;
}
long long inv(long long x) { return modPow(x, M - 2); }
long long divide(long long a, long long b) { return mul(a, inv(b)); }
long long sumofdigits(long long n) {
  if (n < 10) return n;
  long long digit = 0;
  long long sum = 0;
  while (n > 0) {
    digit = n % 10;
    sum = sum + digit;
    n = n / 10;
  }
  return sum;
}
long long modex(long long x, long long y, long long n) {
  if (y == 0) return 1;
  if (y % 2 == 0) {
    long long half_number = modex(x, y / 2, n);
    return (half_number * half_number) % n;
  } else {
    long long half_number = modex(x, y / 2, n);
    half_number = (half_number * half_number) % n;
    half_number = (half_number * x) % n;
    return half_number;
  }
}
vector<long long> createsieve(long long n) {
  vector<long long> primes;
  vector<long long> sieve(n + 1);
  for (long long i = 2; i * i <= n; i++) {
    if (sieve[i] == 0) {
      for (long long j = i * i; j <= n; j += i) {
        sieve[j] = 1;
      }
    }
  }
  for (long long i = 2; i <= n; i++) {
    if (sieve[i] == 0) {
      primes.push_back(i);
    }
  }
  return primes;
}
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
bool isPalindrome(string s, int l, int r) {
  if (l >= r) return true;
  if (s[l] != s[r]) {
    return false;
  }
  return isPalindrome(s, l + 1, r - 1);
}
long long getonebits(long long n) {
  long long count = 0;
  while (n != 0) {
    n = n & (n - 1);
    count++;
  }
  return count;
}
long long fact(long long n) {
  if (n == 0) return 1;
  return n * fact(n - 1);
}
long long inv(long long a, long long m) {
  long long m0 = m, t, q;
  long long x0 = 0, x1 = 1;
  if (m == 1) return 0;
  while (a > 1) {
    q = a / m;
    t = m;
    m = a % m, a = t;
    t = x0;
    x0 = x1 - q * x0;
    x1 = t;
  }
  if (x1 < 0) x1 += m0;
  return x1;
}
long long crt(long long num[], long long rem[], long long k) {
  long long prod = 1;
  for (long long i = 0; i < k; i++) prod *= num[i];
  long long result = 0;
  for (long long i = 0; i < k; i++) {
    long long pp = prod / num[i];
    result += rem[i] * inv(pp, num[i]) * pp;
  }
  return result % prod;
}
long long nCr(long long n, long long r) {
  return fact(n) / (fact(n - r) * fact(r));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long a[n];
    for (long long i = 0; i < n; i++) cin >> a[i];
    long long prevhigh = 0;
    long long prevlow = -1e10;
    long long sum = 0;
    for (long long i = 0; i < n; i++) {
      if (a[i] < 0) {
        prevhigh = 0;
        if (prevlow < a[i]) {
          if (prevlow == -1e10) prevlow = 0;
          sum -= prevlow;
          sum += a[i];
          prevlow = a[i];
        }
      } else if (a[i] > 0) {
        prevlow = -1e10;
        if (prevhigh < a[i]) {
          sum -= prevhigh;
          sum += a[i];
          prevhigh = a[i];
        }
      }
    }
    cout << sum << "\n";
  }
  return 0;
}

### Prompt

Your challenge is to write a CPP solution to the following problem:

Recall that the sequence b is a a subsequence of the sequence a if b can be derived from a by removing zero or more elements without changing the order of the remaining elements. For example, if a=[1, 2, 1, 3, 1, 2, 1], then possible subsequences are: [1, 1, 1, 1], [3] and [1, 2, 1, 3, 1, 2, 1], but not [3, 2, 3] and [1, 1, 1, 1, 2].

You are given a sequence a consisting of n positive and negative elements (there is no zeros in the sequence).

Your task is to choose maximum by size (length) alternating subsequence of the given sequence (i.e. the sign of each next element is the opposite from the sign of the current element, like positive-negative-positive and so on or negative-positive-negative and so on). Among all such subsequences, you have to choose one which has the maximum sum of elements.

In other words, if the maximum length of alternating subsequence is k then your task is to find the maximum sum of elements of some alternating subsequence of length k.

You have to answer t independent test cases.

Input

The first line of the input contains one integer t (1 ≤ t ≤ 10^4) — the number of test cases. Then t test cases follow.

The first line of the test case contains one integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number of elements in a. The second line of the test case contains n integers a_1, a_2, ..., a_n (-10^9 ≤ a_i ≤ 10^9, a_i ≠ 0), where a_i is the i-th element of a.

It is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5 (∑ n ≤ 2 ⋅ 10^5).

Output

For each test case, print the answer — the maximum sum of the maximum by size (length) alternating subsequence of a.

Example

Input


4
5
1 2 3 -1 -2
4
-1 -2 -1 -3
10
-2 8 3 8 -4 -15 5 -2 -3 1
6
1 -1000000000 1 -1000000000 1 -1000000000


Output


2
-1
6
-2999999997

Note

In the first test case of the example, one of the possible answers is [1, 2, \underline{3}, \underline{-1}, -2].

In the second test case of the example, one of the possible answers is [-1, -2, \underline{-1}, -3].

In the third test case of the example, one of the possible answers is [\underline{-2}, 8, 3, \underline{8}, \underline{-4}, -15, \underline{5}, \underline{-2}, -3, \underline{1}].

In the fourth test case of the example, one of the possible answers is [\underline{1}, \underline{-1000000000}, \underline{1}, \underline{-1000000000}, \underline{1}, \underline{-1000000000}].

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 100;
const int M = 1e9 + 7;
long long mod(long long x) { return ((x % M + M) % M); }
long long add(long long a, long long b) { return mod(mod(a) + mod(b)); }
long long mul(long long a, long long b) { return mod(mod(a) * mod(b)); }
long long modPow(long long a, long long b) {
  if (b == 0) return 1LL;
  if (b == 1) return a % M;
  long long res = 1;
  while (b) {
    if (b % 2 == 1) res = mul(res, a);
    a = mul(a, a);
    b = b / 2;
  }
  return res;
}
long long inv(long long x) { return modPow(x, M - 2); }
long long divide(long long a, long long b) { return mul(a, inv(b)); }
long long sumofdigits(long long n) {
  if (n < 10) return n;
  long long digit = 0;
  long long sum = 0;
  while (n > 0) {
    digit = n % 10;
    sum = sum + digit;
    n = n / 10;
  }
  return sum;
}
long long modex(long long x, long long y, long long n) {
  if (y == 0) return 1;
  if (y % 2 == 0) {
    long long half_number = modex(x, y / 2, n);
    return (half_number * half_number) % n;
  } else {
    long long half_number = modex(x, y / 2, n);
    half_number = (half_number * half_number) % n;
    half_number = (half_number * x) % n;
    return half_number;
  }
}
vector<long long> createsieve(long long n) {
  vector<long long> primes;
  vector<long long> sieve(n + 1);
  for (long long i = 2; i * i <= n; i++) {
    if (sieve[i] == 0) {
      for (long long j = i * i; j <= n; j += i) {
        sieve[j] = 1;
      }
    }
  }
  for (long long i = 2; i <= n; i++) {
    if (sieve[i] == 0) {
      primes.push_back(i);
    }
  }
  return primes;
}
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
bool isPalindrome(string s, int l, int r) {
  if (l >= r) return true;
  if (s[l] != s[r]) {
    return false;
  }
  return isPalindrome(s, l + 1, r - 1);
}
long long getonebits(long long n) {
  long long count = 0;
  while (n != 0) {
    n = n & (n - 1);
    count++;
  }
  return count;
}
long long fact(long long n) {
  if (n == 0) return 1;
  return n * fact(n - 1);
}
long long inv(long long a, long long m) {
  long long m0 = m, t, q;
  long long x0 = 0, x1 = 1;
  if (m == 1) return 0;
  while (a > 1) {
    q = a / m;
    t = m;
    m = a % m, a = t;
    t = x0;
    x0 = x1 - q * x0;
    x1 = t;
  }
  if (x1 < 0) x1 += m0;
  return x1;
}
long long crt(long long num[], long long rem[], long long k) {
  long long prod = 1;
  for (long long i = 0; i < k; i++) prod *= num[i];
  long long result = 0;
  for (long long i = 0; i < k; i++) {
    long long pp = prod / num[i];
    result += rem[i] * inv(pp, num[i]) * pp;
  }
  return result % prod;
}
long long nCr(long long n, long long r) {
  return fact(n) / (fact(n - r) * fact(r));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long a[n];
    for (long long i = 0; i < n; i++) cin >> a[i];
    long long prevhigh = 0;
    long long prevlow = -1e10;
    long long sum = 0;
    for (long long i = 0; i < n; i++) {
      if (a[i] < 0) {
        prevhigh = 0;
        if (prevlow < a[i]) {
          if (prevlow == -1e10) prevlow = 0;
          sum -= prevlow;
          sum += a[i];
          prevlow = a[i];
        }
      } else if (a[i] > 0) {
        prevlow = -1e10;
        if (prevhigh < a[i]) {
          sum -= prevhigh;
          sum += a[i];
          prevhigh = a[i];
        }
      }
    }
    cout << sum << "\n";
  }
  return 0;
}

```