#P6102. Bitwise Quadruple Sum
Bitwise Quadruple Sum
Bitwise Quadruple Sum
CYJian wrote an integer sequence (a_1, a_2, \ldots, a_n) and then came up with the following dazzling expression: [ S = \sum_{i=1}^{n}\sum_{j=1}^{n}\sum_{k=1}^{n}\sum_{l=1}^{n} \Bigl((a_i ;\text{or}; a_j) ;\text{xor}; (a_k ;\text{and}; a_l)\Bigr). ] The challenge is to compute (S) modulo (2^{32}) within 1 second. Prove that you can outperform CYJian by computing this value fast!
Note: The operators or
, and
and xor
are bitwise operations.
All formulas are in (\LaTeX) format.
inputFormat
The first line contains a single integer (n) (the length of the sequence).
The second line contains (n) space-separated integers (a_1, a_2, \ldots, a_n).
outputFormat
Output one integer: the value of (S) modulo (2^{32}).
sample
2
0 1
10