#P1848F. Vika and Wiki

    ID: 8585 Type: RemoteJudge 2000ms 256MiB Tried: 0 Accepted: 0 Difficulty: 9 Uploaded By: Tags>binary searchbitmaskscombinatoricsdivide and conquerdpmath*2400

Vika and Wiki

No submission language available for this problem.

Description

Recently, Vika was studying her favorite internet resource - Wikipedia.

On the expanses of Wikipedia, she read about an interesting mathematical operation bitwise XOR, denoted by \oplus.

Vika began to study the properties of this mysterious operation. To do this, she took an array aa consisting of nn non-negative integers and applied the following operation to all its elements at the same time: ai=aia(i+1)modna_i = a_i \oplus a_{(i+1) \bmod n}. Here xmodyx \bmod y denotes the remainder of dividing xx by yy. The elements of the array are numbered starting from 00.

Since it is not enough to perform the above actions once for a complete study, Vika repeats them until the array aa becomes all zeros.

Determine how many of the above actions it will take to make all elements of the array aa zero. If this moment never comes, output 1-1.

The first line contains a single integer nn (1n2201 \le n \le 2^{20}) - the length of the array aa.

It is guaranteed that nn can be represented as 2k2^k for some integer kk (0k200 \le k \le 20).

The second line contains nn integers a0,a1,a2,,an1a_0, a_1, a_2, \dots, a_{n-1} (0ai1090 \le a_i \le 10^9) - the elements of the array aa.

Output a single number - the minimum number of actions required to make all elements of the array aa zero, or 1-1 if the array aa will never become zero.

Input

The first line contains a single integer nn (1n2201 \le n \le 2^{20}) - the length of the array aa.

It is guaranteed that nn can be represented as 2k2^k for some integer kk (0k200 \le k \le 20).

The second line contains nn integers a0,a1,a2,,an1a_0, a_1, a_2, \dots, a_{n-1} (0ai1090 \le a_i \le 10^9) - the elements of the array aa.

Output

Output a single number - the minimum number of actions required to make all elements of the array aa zero, or 1-1 if the array aa will never become zero.

Sample Input 1

4
1 2 1 2

Sample Output 1

2

Sample Input 2

2
0 0

Sample Output 2

0

Sample Input 3

1
14

Sample Output 3

1

Sample Input 4

8
0 1 2 3 4 5 6 7

Sample Output 4

5

Note

In the first example, after one operation, the array aa will become equal to [3,3,3,3][3, 3, 3, 3]. After one more operation, it will become equal to [0,0,0,0][0, 0, 0, 0].

In the second example, the array aa initially consists only of zeros.

In the third example, after one operation, the array aa will become equal to [0][0].