#include <bits/stdc++.h>
int main() {
  int t, n;
  long long tmp, sum;
  scanf("%d", &t);
  while (t--) {
    sum = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
      scanf("%lld", &tmp);
      sum += tmp;
      if (sum < 0) {
        sum = 0;
      }
    }
    printf("%lld\n", sum);
  }
  return 0;
}
