#ifndef LOCAL
#include <bits/stdc++.h>
#define debug(...)
#endif
using namespace std;
#define int long long
#define cinv(v) for (auto &it:v) cin>>it;
#define coutv(v) for (auto &it:v) cout<< it<<' '; cout<<'\n';
const int INF = 2e5 + 5;
void shelby() {
int n;
cin >> n;
vector<int> v(n);
cinv(v)
int sum = accumulate(v.begin(), v.end(), 0LL);
if (find(v.begin(), v.end(), 0) == v.end()) {
cout << "0\n";
return;
}
auto ok = [&](int x)-> bool {
return x * (x + 1) / 2 <= sum;
};
int l = 0, r = INF, ans;
while (l <= r) {
int m = (l + r) / 2;
if (ok(m)) ans = m, l = m + 1;
else r = m - 1;
}
cout << ans + 1 << '\n';
}
signed main() {
cin.tie(0)->sync_with_stdio(0);
int t = 1;
cin >> t;
for (int _ = 1; _ <= t; ++_) {
// cout << "Case " << _ << ": ";
shelby();
}
}