#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long N = 2e5 + 5;
long long n, m, x, y, p, q, k, c, res;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long a[n + 1];
    for (long long i = 0; i < n; i++) cin >> a[i];
    long long sum = 0, ans = 0;
    for (long long i = 0; i < n; i++) {
      sum += a[i];
      if (sum < 0) {
        ans += (abs(sum));
        sum = 0;
      }
    }
    cout << ans << endl;
  }
}
