#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long int t = 1;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    long long int a[n];
    for (long long int i = 0; i < n; i++) cin >> a[i];
    long long int ans = 0;
    long long int sum = 0;
    for (long long int i = n - 1; i >= 0; i--) {
      sum += a[i];
      ans = max(ans, sum);
    }
    cout << ans << '\n';
  }
}
