B: Periodic Sequence
Problem
Dr. Period, who serves as a professor at H University, researches the property called the "period" that is said to lurk in everything. As a basic period generally known, a period lurking in a sequence could be considered. That is, if the length N sequence S = S_1, S_2, ... , S_N satisfies the following property, it is a fact that it has a period t (t \≤ N).
For 1 \≤ i \≤ N − t, S_i=S_{i+t}.
Now, Dr. Period is focusing on sequences that can be described more simply using periods. For example, if a length N sequence has a period t (\≤ N), and it can be written as N=kt using an integer k, the sequence can be described as a length t sequence S_1, ... , S_t that is a concatenation of k continuous ones. Dr. Period has decided to call such a sequence a k-part.
Dr. Period is interested in the largest k-part. Therefore, you, as an assistant, have been asked to create a program that takes a sequence as input and outputs the largest k when it is a k-part. Create a program that accurately responds to Dr. Period's request.
Input Format
N
S_1 ... S_N
The first line contains an integer N, which represents the length of the sequence. The second line contains integers S_i (1 \≤ i \≤ N) that represent each element of the length N sequence, separated by spaces. The input satisfies 1 \≤ N \≤ 200,000 and 1 \≤ S_i \≤ 100,000 (1 \≤ i \≤ N).
Output Format
For the given sequence, output the maximum value of k when it is a k-part on one line.
Sample Input 1
6
1 2 3 1 2 3
Sample Output 1
2
Sample Input 2
12
1 2 1 2 1 2 1 2 1 2 1 2
Sample Output 2
6
Sample Input 3
6
1 2 3 4 5 6
Sample Output 3
1