import numpy as np
N=int(input()) 
A =[list(bin(int(i))[2:].zfill(60)) for i in input().split()] 
keta = np.array([2**(59-i) for i in range(60)])
T = np.zeros((N,60))
for i in range(N):
  T[i] = list(map(int,A[i]))
S = np.sum(T, axis=0)
S = S*(N-S)
print(int(np.dot(S,keta)))