12119 - CS_2018_FINAL-3   

Description

Writer: jjjjj19980806       Description: pclightyear        Difficulty: ★★★

Given n numbers, you need to find a number k such that SUM is minimum,

where we define SUM = ( a1 ^ k ) + ( a2 ^ k ) + ... + ( an ^ k )

(^ stands for the "xor" bitwise operation of the two operand)

Input

The first line contains an integer n, representing the number of numbers.

The next line contains n integers ai, representing each given number.

It is guaranteed that:

  • ≤ 105
  • 0 ≤ ai ≤ 106
  • All numbers ( ai and k ) are unsigned numbers

Output

Please output the value of SUM.

Note SUM may exceed INT.

Sample Input  Download

Sample Output  Download

Tags




Discuss