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
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define all(a) a.begin(),a.end()
#define v vector
#define pb push_back
#define LB lower_bound

v<int>lista;
LL sum=0;
int n;

int czydasie(int x){
    if(sum%x!=0) return 0;
    v<int>pom(n+1,0);
    int od=0, akt=0;
    for(int i=0;i<n;i++){
        
        od+=pom[i];
        akt=lista[i]-od;
        if(akt<0) return 0;
        
        if(akt>0){
            if(i+x>n) return 0;
            od+=akt;
            pom[i+x]-=akt;
        }
    }
    return 1;
}

int main(){ios_base::sync_with_stdio(0);cin.tie(0);
    int akt=1, wyn=1;
    cin >> n;
    lista.resize(n);
    cin >> lista[0];
    sum+=lista[0];
    for(int i=1;i<n;i++){
        cin >> lista[i];
        sum+=lista[i];
        if(lista[i]>=lista[i-1]) akt++;
        else akt=1;
        wyn=max(wyn,akt);
    }
    int wyn1=1;
    for(int i=n-2;i>=0;i--){
        if(lista[i]>=lista[i+1]) akt++;
        else akt=1;
        wyn1=max(wyn1,akt);
    }
    int pom=min(wyn1,wyn);
    while(1){
        if(czydasie(pom)){
            cout << pom;
            return 0;
        }
        pom--;
    }
    
    return 0;
}