28 lines
501 B
Python
28 lines
501 B
Python
#!/usr/bin/env python3
|
|
|
|
import sys
|
|
|
|
def xor_count(a, b):
|
|
xor = a ^ b
|
|
i = 0
|
|
while xor != 0:
|
|
i = i + (xor & 1)
|
|
xor = xor >> 1
|
|
return i
|
|
|
|
|
|
def bitwise_difference(A):
|
|
s = 0
|
|
for i in range(len(A)):
|
|
for j in range(i+1,len(A)):
|
|
s = s + xor_count(A[i], A[j])
|
|
return s
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.stdin.readline()
|
|
A = sys.stdin.readline().split()
|
|
for i in range(len(A)):
|
|
A[i] = int(A[i])
|
|
|
|
print(bitwise_difference(A))
|