1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define ii pair<int,int>
#define iii tuple<int,int,int>
#define fi first
#define se second
#define endl '\n'

#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define lb lower_bound
#define ub upper_bound

#define rep(x,start,end) for(int x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

int n;
int arr[1000005];

bool can(int i){
	int curr=1;
	int sum=0;
	rep(x,1,i+1){
		while (curr<=n && sum>=arr[curr]){
			curr++;
			sum=0;
		}
		if (curr==n+1) return true;
		
		sum+=(x-1)*(i-x);
	}
	
	while (curr<=n && sum>=arr[curr]){
		curr++;
		sum=0;
	}
	if (curr==n+1) return true;
	return false;
}

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin.exceptions(ios::badbit | ios::failbit);
	
	int TC;
	cin>>TC;
	while (TC--){
		cin>>n;
		rep(x,1,n+1) cin>>arr[x];
		
		int lo=0,hi=1000005,mi;
		while (hi-lo>1){
			mi=hi+lo>>1;
			
			if (can(mi)) hi=mi;
			else lo=mi;
		}
		
		cout<<hi<<endl;
	}
}