N = int(input())
A = input().split()
A = [int(a) for a in A]
max_A = max(A)
max_keta = len((bin(max_A))[2:])
A = [bin(a)[2:] for a in A]
for i in range(N):
    s = A[i]
    while(len(s)<max_keta):
        s = "0"+s
    A[i] = s
zero = [0 for i in range(max_keta)]
one = [0 for i in range(max_keta)]

for i in range(N):
    for j in range(max_keta):
        if(A[i][j]=="0"):
            zero[max_keta-1-j] += 1
        else:
            one[max_keta-1-j] += 1


sum_ = 0
for i in range(max_keta):
    sum_ += one[i]*zero[i]*(2**(i))
    sum_ = sum_%1000000007
    
print(sum_)