#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    long long int arr[n], s = 0;
    for (int i = 0; i < n; i++) {
      cin >> arr[i];
      s += arr[i];
      s = max(s, 0ll);
    }
    cout << s << endl;
  }
}
