#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
namespace IO {
bool REOF = 1;
inline char nc() {
  static char buf[1 << 20], *p1 = buf, *p2 = buf;
  return p1 == p2 && REOF &&
                 (p2 = (p1 = buf) + fread(buf, 1, 1 << 20, stdin), p1 == p2)
             ? (REOF = 0, EOF)
             : *p1++;
}
template <class T>
inline bool read(T &x) {
  char c = nc();
  bool f = 0;
  x = 0;
  while (c < '0' || c > '9') c == '-' && (f = 1), c = nc();
  while (c >= '0' && c <= '9') x = (x << 3) + (x << 1) + (c ^ 48), c = nc();
  if (f) x = -x;
  return REOF;
}
template <class T>
inline void write(T x) {
  if (x > 9) write(x / 10);
  putchar('0' + x % 10);
}
template <typename T, typename... T2>
inline bool read(T &x, T2 &...rest) {
  read(x);
  return read(rest...);
}
inline bool need(char &c) {
  return ((c >= 'a') && (c <= 'z')) || ((c >= '0') && (c <= '9')) ||
         ((c >= 'A') && (c <= 'Z'));
}
inline bool read_str(char *a) {
  while ((*a = nc()) && need(*a) && REOF) ++a;
  *a = '\0';
  return REOF;
}
inline bool read_db(double &x) {
  bool f = 0;
  char ch = nc();
  x = 0;
  while (ch < '0' || ch > '9') {
    f |= (ch == '-');
    ch = nc();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10.0 + (ch ^ 48);
    ch = nc();
  }
  if (ch == '.') {
    double tmp = 1;
    ch = nc();
    while (ch >= '0' && ch <= '9') {
      tmp = tmp / 10.0;
      x = x + tmp * (ch ^ 48);
      ch = nc();
    }
  }
  if (f) x = -x;
  return REOF;
}
template <class TH>
inline void _dbg(const char *sdbg, TH h) {
  cerr << sdbg << '=' << h << '\n';
}
template <class TH, class... TA>
inline void _dbg(const char *sdbg, TH h, TA... a) {
  while (*sdbg != ',') cerr << *sdbg++;
  cerr << '=' << h << ',' << ' ';
  _dbg(sdbg + 1, a...);
}
template <class T>
ostream &operator<<(ostream &os, vector<T> V) {
  os << "[ ";
  for (auto vv : V) os << vv << ",";
  return os << " ]";
}
template <class T>
ostream &operator<<(ostream &os, set<T> V) {
  os << "[ ";
  for (auto vv : V) os << vv << ",";
  return os << " ]";
}
template <class T>
ostream &operator<<(ostream &os, map<T, T> V) {
  os << "[ ";
  for (auto vv : V) os << vv << ",";
  return os << " ]";
}
template <class L, class R>
ostream &operator<<(ostream &os, pair<L, R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
}  // namespace IO
using namespace IO;
const int N = 2e5 + 5;
const int M = 5e5 + 5;
const int MAXV = 1e6 + 5;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long LLINF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;
int n;
long long a[N];
void solve(int Case) {
  read(n);
  for (int i = 0; i < n; ++i) read(a[i]);
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    int j = i + 1;
    long long val = a[i];
    while (j < n) {
      long long mul = 1ll * a[i] * a[j];
      if (mul < 0) break;
      val = max(val, a[j]);
      j++;
    }
    ans += val;
    i = j - 1;
  }
  printf("%lld\n", ans);
}
int main() {
  int _T;
  read(_T);
  for (int _ = 1; _ <= _T; _++) solve(_);
  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 double pi = acos(-1.0);
namespace IO {
bool REOF = 1;
inline char nc() {
  static char buf[1 << 20], *p1 = buf, *p2 = buf;
  return p1 == p2 && REOF &&
                 (p2 = (p1 = buf) + fread(buf, 1, 1 << 20, stdin), p1 == p2)
             ? (REOF = 0, EOF)
             : *p1++;
}
template <class T>
inline bool read(T &x) {
  char c = nc();
  bool f = 0;
  x = 0;
  while (c < '0' || c > '9') c == '-' && (f = 1), c = nc();
  while (c >= '0' && c <= '9') x = (x << 3) + (x << 1) + (c ^ 48), c = nc();
  if (f) x = -x;
  return REOF;
}
template <class T>
inline void write(T x) {
  if (x > 9) write(x / 10);
  putchar('0' + x % 10);
}
template <typename T, typename... T2>
inline bool read(T &x, T2 &...rest) {
  read(x);
  return read(rest...);
}
inline bool need(char &c) {
  return ((c >= 'a') && (c <= 'z')) || ((c >= '0') && (c <= '9')) ||
         ((c >= 'A') && (c <= 'Z'));
}
inline bool read_str(char *a) {
  while ((*a = nc()) && need(*a) && REOF) ++a;
  *a = '\0';
  return REOF;
}
inline bool read_db(double &x) {
  bool f = 0;
  char ch = nc();
  x = 0;
  while (ch < '0' || ch > '9') {
    f |= (ch == '-');
    ch = nc();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10.0 + (ch ^ 48);
    ch = nc();
  }
  if (ch == '.') {
    double tmp = 1;
    ch = nc();
    while (ch >= '0' && ch <= '9') {
      tmp = tmp / 10.0;
      x = x + tmp * (ch ^ 48);
      ch = nc();
    }
  }
  if (f) x = -x;
  return REOF;
}
template <class TH>
inline void _dbg(const char *sdbg, TH h) {
  cerr << sdbg << '=' << h << '\n';
}
template <class TH, class... TA>
inline void _dbg(const char *sdbg, TH h, TA... a) {
  while (*sdbg != ',') cerr << *sdbg++;
  cerr << '=' << h << ',' << ' ';
  _dbg(sdbg + 1, a...);
}
template <class T>
ostream &operator<<(ostream &os, vector<T> V) {
  os << "[ ";
  for (auto vv : V) os << vv << ",";
  return os << " ]";
}
template <class T>
ostream &operator<<(ostream &os, set<T> V) {
  os << "[ ";
  for (auto vv : V) os << vv << ",";
  return os << " ]";
}
template <class T>
ostream &operator<<(ostream &os, map<T, T> V) {
  os << "[ ";
  for (auto vv : V) os << vv << ",";
  return os << " ]";
}
template <class L, class R>
ostream &operator<<(ostream &os, pair<L, R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
}  // namespace IO
using namespace IO;
const int N = 2e5 + 5;
const int M = 5e5 + 5;
const int MAXV = 1e6 + 5;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long LLINF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;
int n;
long long a[N];
void solve(int Case) {
  read(n);
  for (int i = 0; i < n; ++i) read(a[i]);
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    int j = i + 1;
    long long val = a[i];
    while (j < n) {
      long long mul = 1ll * a[i] * a[j];
      if (mul < 0) break;
      val = max(val, a[j]);
      j++;
    }
    ans += val;
    i = j - 1;
  }
  printf("%lld\n", ans);
}
int main() {
  int _T;
  read(_T);
  for (int _ = 1; _ <= _T; _++) solve(_);
  return 0;
}

```