#include <bits/stdc++.h>
long long int ceiil(long long int x, long long int y) {
  return x / y + (x % y != 0);
}
const long long int N = 1e5 + 10;
using namespace std;
bool isvowel(char c) {
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'A' ||
      c == 'E' || c == 'I' || c == 'O' || c == 'U')
    return true;
  return false;
}
long long int fast_exp(long long int x, long long int n) {
  long long int ans = 1;
  while (n) {
    if (n & 1) ans *= x;
    n = n >> 1;
    x = x * x;
  }
  return ans;
}
long long int mod_exp(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long int sod(long long int n) {
  long long int sum = 0;
  while (n != 0) {
    sum = sum + (n % 10);
    n = n / 10;
  }
  return sum;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, i, j;
    cin >> n;
    vector<long long int> vec(n), sum(n);
    for (i = 0; i < n; i++) cin >> vec[i];
    sum[0] = vec[0];
    for (i = 1; i < n; i++) {
      sum[i] = sum[i - 1] + vec[i];
    }
    long long int ans = 0;
    for (i = 0; i < n; i++) {
      if (sum[i] < 0) {
        ans = max(ans, abs(sum[i]));
      }
    }
    cout << ans << endl;
  }
}
