N = int(input())
A = list(map(int,input().split()))

ans = 0
for i in range(61):
  c0 = 0
  c1 = 0
  for a in A:
    if (a>>i)&1 == 1:
      c1 += 1
    else:
      c0 += 1
  #print(c1,c0)
  ans += ((c0*c1)<<i)
print(ans)
