#include <bits/stdc++.h>
using namespace std;
double power(float x, int y) {
  float temp;
  if (y == 0) return 1;
  temp = power(x, y / 2);
  if (y % 2 == 0)
    return temp * temp;
  else {
    if (y > 0)
      return x * temp * temp;
    else
      return (temp * temp) / x;
  }
}
bool isPrime(int n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
void solve() {
  long long int n;
  cin >> n;
  vector<long long int> a(n);
  for (long long int i = 0; i < n; i++) cin >> a[i];
  ;
  long long int ans = a[0];
  long long int t = a[0];
  for (long long int i = 1; i < n; i++) {
    t += a[i];
    ans = min(ans, t);
  }
  cout << abs(ans) << endl;
}
int main() {
  long long int t;
  cin >> t;
  while (t--) solve();
}
