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

b=max(a)
k=0

while b!=0:
    b=b//2
    k+=1

ans=0

for i in range(k):
    x=0
    y=0
    for j in range(n):
        if (a[j]>>i)%2==1:
            x+=1
        else:
            y+=1
    ans+=(2**i)*(x*y)
print(ans)