n=int(input())
a=list(map(int,input().split()))
ma=max(a)
ct=0
while ma>0:
  ma//=2
  ct+=1
lis=[0 for _ in range(ct)]

for i in range(n):
  digit=ct
  while digit>0:
    if a[i] >= 2**(digit-1):
      a[i]-=2**(digit-1)
      lis[digit-1]+=1
    digit-=1

lis2=[n-x for x in lis]
ans=0
for i in range(ct):
  ans+=lis[i]*lis2[i]*2**i
print(ans)