Professional Documents
Culture Documents
Your task is to divide the array into the maximum number of segments in such a way that:
each element is contained in exactly one segment;
each segment contains at least one element;
there doesn't exist a non-empty subset of segments such that bitwise XOR of the numbers from
them is equal to 00.
Print the maximum number of segments the array can be divided into. Print -1 if no suitable division
exists.
Input
The first line contains a single integer nn (1≤n≤2⋅1051≤n≤2⋅105) — the size of the array.
The second line contains nn integers a1,a2,…,ana1,a2,…,an (0≤ai≤1090≤ai≤109).
Output
Print the maximum number of segments the array can be divided into while following the given
constraints. Print -1 if no suitable division exists.
Examples
input
Copy
4
5 5 7 2
output
Copy
2
input
Copy
3
1 2 3
output
Copy
-1
input
Copy
3
3 1 10
output
Copy
3