#include <bits/stdc++.h>
using namespace std;
int main() {
  long t;
  scanf("%ld", &t);
  while (t--) {
    long long n, i, j, k = 0, c = 0;
    cin >> n;
    for (i = 0; i < n; i++) cin >> j, k += j, c = min(c, k);
    cout << -c << endl;
  }
  return 0;
}
