#abc281f. [abc281_f]Xor Minimization

[abc281_f]Xor Minimization

Problem Statement

You are given a sequence of non-negative integers A=(a1,ldots,aN)A=(a_1,\\ldots,a_N).

Let us perform the following operation on AA just once.

  • Choose a non-negative integer xx. Then, for every i=1,ldots,Ni=1, \\ldots, N, replace the value of aia_i with the bitwise XOR of aia_i and xx.

Let MM be the maximum value in AA after the operation. Find the minimum possible value of MM.

What is bitwise XOR? The bitwise XOR of non-negative integers AA and BB, AoplusBA \\oplus B, is defined as follows.

  • When AoplusBA \\oplus B is written in binary, the kk-th lowest bit (kgeq0k \\geq 0) is 11 if exactly one of the kk-th lowest bits of AA and BB is 11, and 00 otherwise.

For instance, 3oplus5=63 \\oplus 5 = 6 (in binary: 011oplus101=110011 \\oplus 101 = 110).

Constraints

  • 1leqNleq1.5times1051 \\leq N \\leq 1.5 \\times 10^5
  • 0leqailt2300 \\leq a_i \\lt 2^{30}
  • All values in the input are integers.

Input

The input is given from Standard Input in the following format:

NN a1a_1 ldots\\ldots aNa_N

Output

Print the answer.


Sample Input 1

3
12 18 11

Sample Output 1

16

If we do the operation with x=2x=2, the sequence becomes $(12 \\oplus 2,18 \\oplus 2, 11 \\oplus 2) = (14,16,9)$, where the maximum value MM is 1616.
We cannot make MM smaller than 1616, so this value is the answer.


Sample Input 2

10
0 0 0 0 0 0 0 0 0 0

Sample Output 2

0

Sample Input 3

5
324097321 555675086 304655177 991244276 9980291

Sample Output 3

805306368