#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    long long int sum = 0;
    for (int i = 0; i < n; i++) {
      long long int x, k = 0;
      cin >> x;
      sum += x;
      if (sum >= 0) {
        sum = sum;
      } else {
        sum = 0;
      }
    }
    cout << sum << endl;
  }
}
