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
#include<bits/stdc++.h>

using namespace std;

const int maxn=1e5 + 9;
long long n, tab[maxn], sumy[maxn * 2];

bool sprawdz(long long k) {
	long long suma=0, ile;
	for(int i=1; i<=n; i++) {
		ile = tab[i] - suma;
		//cout << "JESTEM: " << i << "   " << ile << endl;
		if(ile<0) {
			return 0;
		}	
		if((i>(n-k+1)) && ile!=0) {
			return 0;
		}	 
		
		suma+=ile;
		sumy[i+k-1]=ile;
		
		if(i>=k) {
			suma -= sumy[i];
		}	
	}
	return 1;	
}	

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	long long a, suma=0;
	cin >> n;
	for(long long i=1; i<=n; i++) {
		cin >> a;
		tab[i]=a;
		suma+=a;
	}
	for(long long i=n; i>=2; i--) {
		if(suma%i == 0) {
			//cout << "SPRAWDZAM: " << i << endl;
			if(sprawdz(i)) {
				cout << i;
				return 0;
			}	
		}	
	}
	cout << 1;
	return 0;
}