#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    vector<long long int> v(n);
    for (long long int i = 0; i < n; i++) cin >> v[i];
    long long int sum = v[0], ans = 0;
    for (long long int i = 1; i < n; i++) {
      if (sum < 0) ans = max(ans, abs(sum));
      sum += v[i];
    }
    cout << ans << endl;
  }
  return 0;
}
