#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long n, i, cnt = 0;
    cin >> n;
    long long a[n + 2];
    for (i = 1; i <= n; i++) cin >> a[i], cnt = max(0ll, cnt + a[i]);
    cout << cnt << "\n";
  }
}
