Placement Question

This question was asked in placement exam of a Company. I was not able to understand this problem.

Here is the screen shot of the problem (reputation is less than 60 so can’t attach image here) —> click here


The first line of input contains N which is number of jugs and the next line contains N integers representing number of balls in each jug.

Input:

1

10

Output:

10


Please, someone help me to understand this problem, and if possible suggest a solution as well.

It is a minor variation on the game of Nim. The aim of any move is to make the exclusive-or of the numbers of balls in the jugs compute to zero.

Just take bitwise XOR of input say it is x, so if x is 0 return -1 else return x