n = int(input())
a = list(map(int,input().split()))

mm0 = [0 for i in range(61)]
mm1 = [0 for i in range(61)]

for i in range(n):
    for j in range(61):
        if (a[i]>>j)<0:
            break
        if (a[i]>>j)&1:
            mm1[j] += 1

for i in range(61):
    mm0[i] = n-mm1[i] 

ans = 0

for i in range(61):
    ttl = mm0[i]*mm1[i]
    ans += (1<<i)*ttl

print(ans)
