#Lutece1041. Hug the princess
Hug the princess
Migrated from Lutece 1041 Hug the princess
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
There is a sequence with elements. Assuming they are .
Please calculate the following expession.
$\displaystyle{\sum_{1\leq i < j \leq n} (a_i \wedge a_j)+(a_i | a_j)+(a_i \& a_j)}$
In the expression above, ^
|
&
is bit operation. If you don’t know bit operation, you can visit Bitwise operation to get some useful information.
Input
The first line contains a single integer , which is the size of the sequence.
The second line contains integers, the integer is the element of the sequence.
Output
Print the answer in one line.
Samples
2
1 2
6
Note
Because the answer is so large, please use long long instead of int. Correspondingly, please use %lld
instead of %d
to scanf and printf.
Large input. You may get Time Limit Exceeded if you use "cin" to get the input. So "scanf" is suggested.
Likewise, you are supposed to use "printf" instead of "cout".
Resources
The 13th UESTC Programming Contest Preliminary