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
#include<bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimize ("Ofast")
using namespace std;
#define int long long
typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define all(x) (x).begin(), (x).end()

int tab[100007];
int chk[100007];

void solve() {
    int n, i, j, sum=0, cur, ans=0;
    bool ok;
    cin >> n;
    for(i=0; i<n; i++){
        cin >> tab[i];
        sum+=tab[i];
    }
    for(i=1;i<=n; i++){
        if(sum%i!=0) continue;
        // cout << i << '\n';cout.flush();
        cur=0;
        ok=true;
        for(j=0; j<n; j++){
            if(j>=i) cur-=chk[j];
            // cout << cur << ' ';
            if(cur>tab[j] || (cur<tab[j] && i+j>=n+1)){
                ok=false;
                break;
            }
            if(i+j<n) chk[i+j]=tab[j]-cur;
            // chk[i+j]=tab[j]-cur;
            // cout << chk[i+j] << ' ';
            cur=tab[j];
        }
        // cout << '\n';
        if(ok) ans=i;
    }
    cout << ans << '\n';
}

signed main () {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while(t-- ) solve();
}