In Professor VKJ's class there are n students and Kuldeep is a TA in the class. So to test the knowledge of Kuldeep he wrote n numbers on the blackboard and asked the question to Kuldeep that if all the students come one by one and decide either to do nothing or choose a number from the blackboard let's say x and then change all numbers on the blackboard with their bitwise xor with x, in other words replace all ai by ai^x, where ai denotes the ith number written on the blackboard (1 <= i <= n). Read more about bitwise xor here. What will be the maximum sum of numbers at the end on the blackboard that we can get by changing the numbers with the given operations?
Let's suppose if we have {a1,a2,a3…an} on the blackboard and one student come he can either decide to do nothing and all the numbers on the blackboard remain the same, or choose a number x from {a1,a2,a3…an} and replace all numbers on the blackboard with their bitwise xor with x. Now the new numbers on the blackboard are {a1^x,a2^x,a3^x…..an^x}.
Kuldeep was able to solve this problem, can you solve it?
Input Format
The first line of input is n the number of students in the class. 1<=n<=3*1e5
The next line contain the n numbers written on the blackboard {a1,a2,a3......an} 0<=ai<2^30, for all 1 <= i <= n
Output Format
Output should contain single integer which will be the maximum sum of numbers at the end out of all possibilities
PS: Jumping around is considered a bad habit, but sometimes it is good.
In the above sample case VKJ initially wrote the numbers {3 1 4 1 5} on the blackboard
The first student came and chose x=1 and then replace all the numbers on the blackboard with their xor with x now the new number on the blackboard are {2 0 5 0 4}
The second student came and chose to do nothing hence the numbers remains the same.
The third student decide to do the same and do nothing
The fourth student chose x=4 and then the new numbers on blackboard are {6 4 1 4 0}
The fifth student chose x=1 and the numbers on blackboard change to {7 5 0 5 1}
Hence in the end we got sum of numbers 7+5+0+5+1=18 and it can we shown that we can not get sum greater than 18 in this case.