n=int(input())
a=list(map(int,input().split()))
keta=[0 for i in range(n)]
ans=0
for i in range(n):
  b=a[i]
  cnt=0
  while(b>=1):
    if b%2==1:
      keta[cnt]+=1
    b=b//2
    cnt+=1
#print(keta)
for i in range(len(keta)):
  #print(keta[i])
  ans+=keta[i]*(n-keta[i])*(2**i)
print(ans)