## SGS Programming Challenge P1 - XOR in Computer Class

View as PDF

Points: 7 (partial)
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type

Andy recently learned about the bitwise XOR operation in computer class.

One of Andy's friends owns an array , which has a length of . Andy wants to make his friend sad by XORing all of the numbers in by a non-negative number such that the sum of the sums of each subarray is minimal. Since Andy is not an expert at XOR, he asks you to find for him. If multiple solutions exist for , output the smallest one.

Recall subarrays are consecutive subsequences. For example, the subarrays of the array are . The sum of the sums of each subarray for this array will be .

#### Input Specification

The first line contains an integer .

The second line contains integers, his friend's array .

#### Output Specification

Output the minimal solution for , which is the number that Andy wishes to know.

#### Sample Input 1

3
1 2 3

#### Sample Output 1

3

#### Explanation for Sample 1

After XORing by 3, the array becomes . The sum of the sums of each subarray is . It can be shown that is the smallest possible sum of the sums of each subarray.

#### Sample Input 2

7
7 9 10 43 56 2 4

#### Sample Output 2

10