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
71
72
73
74
75
76
#include <bits/stdc++.h> 
using namespace std;
#define st first
#define nd second
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int maxn = 200009;
int a[maxn];
int N;


bool f(ll X)
{
    ll pop = 0;
    ll akt = 0;

    for(int i = 0 ; i < N ; i++)
    {
        while(pop*akt*X + (akt*(akt-1))/2*pop + (akt*(akt-1))/2*X + (akt*(akt-1)*(akt-2))/6< a[i])
        {
            akt++;
            X--;
            if(X < 0)return false;
        }
        pop += akt;
        akt = 0;
    } 

    return true;
}


int bs()
{
    int pocz = 0 , kon = (1e+6)*100+9 , sro;
    while(kon-pocz > 1)
    {
        sro = (pocz+kon)/2;
        if(f(sro))kon = sro;
        else pocz = sro;
    }

    return kon;
}

void solve()
{
    cin >> N;
    for(int i = 0; i < N ; i++)
    {
        cin >> a[i];
    }

    cout << bs() << '\n';
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int te;
    cin >> te;
    while(te--)
    {
        solve();
    }
    


    
   
    
    return 0;
}