import math
n = int(input())
a = [int(i) for i in input().split()]
b = []

nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r)%(10**9-7) + cmb(n-1,r-1) % (10**9-7)
    return nCr[(n,r)]


for i in a:
    b.append(format(i,'0' + str(len(format(max(a),'b')))+'b'))
#print(b)
l = len(b[0])
dic = {}
for j in range(l):
    dic[2 ** (j)] = 0
#print(dic)
for i in range(n):
    for j in range(l):
        if b[i][j] == '1':
            dic[2 ** (l-j-1)] += 1 #1の回数
ans  = 0
for i in dic.keys():
#    print(i)
    if dic[i] < 2:
        only1 = 0
    else:
        only1 = cmb(dic[i],2)
    if n - dic[i] < 2:
        only0 = 0
    else:
        only0 = cmb(n - dic[i],2)
    #print(only0,only1)
    ans += i * (cmb(n,2) - only0 - only1)
print(ans)
