#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5, inf = 2147483647, INF = 1e9;
long long t, n, a[N], ans, cnt;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  cin >> t;
  while (t--) {
    cin >> n;
    ans = 0, cnt = 0;
    for (int i = 1; i <= n; ++i) {
      cin >> a[i];
    }
    for (int i = 1; i <= n; ++i) cnt += a[i], ans = min(cnt, ans);
    cout << -ans << endl;
  }
  return 0;
}
