#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define ll long long
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;
        vector<ll> a(n);
        for (int i = 0; i < n; ++i) {
            cin >> a[i];
        }
        
        int cnt = 0;
        ll c = 0;
        for (int idx = n - 1; idx >= 0; --idx) {
            ll cur = a[idx] + c;
            if (cur > 0) {
                ++cnt;
                c = cur;
            } 
			else {
                c = 0;
            }
        }
        
        cout << cnt << '\n';
    }
    
    return 0;
}
