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
#include<iostream>
#include<vector>

#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define FORD(i,a,b) for(int i=(a);i>=(b);--i)

using namespace std;

const int MAX_N = 100000;

int A[MAX_N], B[MAX_N], D[MAX_N+1], Q[MAX_N+1]; 

int res, n, k;

int main(void) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n;
	
	REP(i, n) { cin >> A[i]; }

	D[0] = A[0];
	FOR(i, 1, n) D[i] = A[i] - A[i-1];

	FOR(k, 1, n) Q[k] = 1;

	res = 1;
	
	FOR(k, 2, n) if (Q[k]) {
		bool ok = true;
		REP(i, k) {
			long long s = 0;
			int j = 0;
			while (i+k*j <= n) {
				s += D[i+k*j];
				j++;
			}
			if (s != 0) {
				ok = false;
				break;
			}
		}
		if (ok) {
			//cerr << "k=" << k << endl;
			REP(i, n) { B[i] = A[i]; }
			REP(i, n) if (B[i]) {
				//cerr <<"i=" << i << " B[]={"; REP(q, n) cerr << B[q] << " "; cerr << "}" << endl;
				FOR(j, 1, k-1) {
					if (i+j >= n) break;
					if ((B[i+j] -= B[i]) < 0) {
						ok = false; 
						break;
					}
				}
				B[i] = 0;
				if (!ok) break;
			}
			//cerr << "k=" << k << " ok=" << ok << endl;
		}
		if (ok) {
			res = k;
		} else {
			int j = k;
			while(j <= n) { Q[j] = 0; j+=k; }
		}
	}
		
	cout << res << endl;

	return 0;
}