NR2 - Bhagat The Bit Man


Bhagat is student of CSE at ISM Dhanbad. In mid-semsester exam somehow he was able to score full marks in Boolean algebra. So his profs doubt how can he score full marks. So profs decided to check his ability. They gave Bhagat a list student’s admission number and ask him to find total kaptiness (K) of list.

Kaptiness is defined as or operation on every dukkerness(di) value. Dukkerness value is xor operation on every pair of number in list.As we all know Bhagat is not good in Boolean algebra. Can you help him to prove his profs that he can score full out of full in boolean algebra.

Example:-

If list contain three number 10, 15 & 17.Then there will be total 3 pairs.

d1 = 10 ^ 15 = 5;

d2 = 10 ^ 17 = 27;

d3 = 17 ^ 15 = 30;

k = d1 | d2 | d3 ;

K = 31;

Input

First line of input contain N (2 <= N <= 106). N is total number of admission number(ai) in list.

Then following N line will contain admission number. (0 <= a<=1018)

Output

Output only one line containing K.

Example

Input:
3
10
15
17

Output:
31

NOTE: Large input data.

test cases have been updated and all solutions are rejudged.


hide comments
samanwaya: 2017-04-02 10:10:10

Worth solving learnt a lot!!!

dwij28: 2016-04-07 18:57:06

Nice and simple .. :)

kejriwal: 2016-01-05 18:30:23

comments are spoilers :P !

Siddharth Singh: 2015-12-25 09:41:32

Learnt Something New , thanks To K MAPS

MAYANK NARULA: 2015-10-17 12:41:45

It's easy if u didn't neglect K-Maps in HIGH SCHOOL

Shivam Singh: 2015-08-21 05:36:18

try this one to have fun with some Boolean Algebra
**********
just simplify this expression for help, you will get the trick

Last edit: 2015-09-22 15:40:40
arpit: 2015-06-24 20:57:12

nice problem...

Baymax: 2015-05-26 03:14:43

use scanf/printf instead of cin/cout ...

:.Mohib.:: 2015-02-14 15:18:31

Realy enjoyed....nice problem....

Martin Radev: 2014-04-29 02:03:06

Also, I am interested in other people's solutions since I see there are such under 1 second.
--ans(Francky)--> There's only one good solution (the same for all AC I suppose), faster ones use only much faster IO methods.

Last edit: 2014-04-29 10:36:04

Added by:NISHANT RAJ
Date:2014-03-11
Time limit:0.168s-0.485s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:own