#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long a[n];
    long long sum = 0;
    long long sum_ = 0;
    for (long long i = 0; i < n; i++) {
      cin >> a[i];
      sum += a[i];
      if (sum >= 0) {
        continue;
      }
      if (sum < 0) {
        sum_ += -sum;
        sum = 0;
      }
    }
    cout << sum_ << endl;
  }
  return 0;
}
