#include <bits/stdc++.h>
using namespace std;

vector<int> XX( int N ) {
	vector<int >ret;
	for( size_t i = 1; i <= sqrtl( N ); i++ ) {
		if( N%i == 0 ) {
			ret.push_back( i );
			ret.push_back( N / i );
		}
	}
	return ret;
}

int main() {
	int N;
	cin >> N;
	vector<int>data( N );
	auto XXX = XX( N );
	for( size_t i = 0; i < N; i++ ) {
		cin >> data[i];
	}
	long long int ans = 0;
	for( size_t i = 0; i < XXX.size(); i++ ) {
		bool f = 1;
		for( size_t j = 0; j < XXX[i]; j++ ) {
			for( size_t k = 0; k < N / XXX[i]; k++ ) {
				if( data[k] != data[k + j*N / XXX[i]] ) {
					f = 0;
				}
			}
		}
		if( f ) {
			if( ans < XXX[i] ) {
				ans = XXX[i];
			}
		}
	}
	cout << ans << endl;
}