XMAX - XOR Maximization

no tags 

Given a set of integers S = { a1, a2, a3, ... a|S| }, we define a function X on S as follows:
X( S ) = a1 ^ a2 ^ a3 ^ ... ^ a|S|.
(^ stands for bitwise 'XOR' or 'exclusive or')

Given a set of N integers, compute the maximum of the X-function over all the subsets of the given starting set.

Input

The first line of input contains a single integer N, 1 <= N <= 105.
Each of the next N lines contain an integer ai, 1 <= ai <= 1018.

Output

To the first line of output print the solution.

Example

Input:
3
1
2
4

Output:
7

hide comments
sleepntsheep: 2024-04-19 16:18:51

xor basis

jiekai: 2020-05-27 05:54:18

Is there an input format problem?

zbillion_: 2020-05-24 17:37:14

another input
3
8 9 5
ans-13

toyford: 2020-04-23 20:17:30

Runtime error in python
WA in cpp :(
Can anyone share 'AC' solution for this?

Last edit: 2020-04-23 20:26:19
drdrunkenstein: 2019-08-14 04:59:17

Runtime error in python

Simes: 2019-08-11 20:40:15

-1 for badly formatted input

akibk001: 2019-04-02 15:11:42

use power(2,i) for shifting purpose..

whyamievenhere: 2018-12-18 17:10:50

ridiculous time limit,,

be1035016: 2018-06-17 10:32:46

learnt something new:)

singh_811: 2017-08-25 09:48:25

*******************BEWARE******************
Input is not formatted as described it cost me 3 WAs.

Last edit: 2017-08-25 09:49:01

Added by:gustav
Date:2011-01-26
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:classical problem