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
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <queue>
using namespace std;

//typy
using ll = long long;
using pll = pair <long long, long long>;
using pii = pair <int, int>;
using ull = unsigned long long;


//vectory
#define all(_) (_).begin(), (_).end()
#define vec vector
using vl = vector <ll>;
using vi = vector <int>;
using vs = vector <string>;
using vc = vector <char>;
using vpll = vector <pair <long long, long long> >;
using vpii = vector <pair <int, int> >;
using vvint = vector<vector<int>>;
using vvll = vector<vector<long long>>;
using vb = vector <bool>;
using ld = long double;

//mapy, sety
using mll = map <long long, long long>;
using mii = map <int, int>;
using mss = map <string, string>;
using mcc = map <char, char>;
using sl = set <long long>;
using si = set <int>;
using ss = set <string>;
using sc = set <char>;

//unordered mapy, sety
using umll = unordered_map <long long, long long>;
using umii = unordered_map <int, int>;
using umss = unordered_map <string, string>;
using umcc = unordered_map <char, char>;
using usl = unordered_set <long long>;
using usi = unordered_set <int>;
using uss = unordered_set <string>;
using usc = unordered_set <char>;

//tak, nie
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define TAK cout<<"TAK\n"
#define NIE cout<<"NIE\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
#define Tak cout<<"Tak\n"
#define Nie cout<<"Nie\n"
#define yes cout<<"yes\n"
#define no cout<<"no\n"
#define tak cout<<"tak\n"
#define nie cout<<"nie\n"

//inne
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define LINIJKI ios_base::sync_with_stdio(0);cin.tie(0);
#define sorall(x) sort(x.begin(), x.end());
#define sorcmp(x, cmp) sort(x.begin(), x.end(), cmp);
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define per(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define nl '\n'
#define elif else if
#define vecout(v) {for(auto _:(v)) cout << _ << ' '; cout << "\n";}
#define wczyt(v) for(auto &_:(v)) cin >> (_);
//-----------------------------------------------------
const bool db = false;
vl l;
ll n, suma = 0;

bool sprawdz(ll k){
    if(k == 1) return true;
    if(suma%k != 0) return false;
    ll okno = 0;
    vl fale(n, 0);
    for(ll i = 0; i + k - 1 < n; i++){
        if(i >= k){
            okno -= fale[i-k];
        }
        if(l[i] - okno < 0){
            return false;
        }else{
            fale[i] = l[i]-okno;
        }
        okno += fale[i];
    }
    for(ll i = n-k+1; i < n; i++){
        if(i >= k){
            okno -= fale[i-k];
        }
        if(l[i] - okno != 0) return false;
    }
    return true;
}

int main(){
    LINIJKI
    cin >> n;
    l.resize(n);
    for(auto &i:l){
        cin >> i;
        suma += i;
    }
    for(ll i = n; i >= 1; i--){
        if(sprawdz(i)){
            cout << i;
            return 0;
        }
    }

}