#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  scanf("%d", &t);
  int n;
  long long res, x;
  while (t--) {
    res = 0;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
      scanf("%lld", &x);
      res = max(0ll, res + x);
    }
    printf("%lld\n", res);
  }
  return 0;
}
