import numpy as np
n = int(input())
arr = list(map(int,input().split()))
buf = [0 for i in range(61)]

count = [[0,0] for i in range(61)]

for a in arr:
    txt = str(bin(a))[2:].zfill(61)

    for i in range(len(txt)):
        if txt[i] == "0":
            buf[i] += count[i][1]
            count[i][0] += 1
        else:
            buf[i] += count[i][0]
            count[i][1] += 1

m = 10**9 +7

buf.reverse()
ans = 0

for i in range(len(buf)):
    num = buf[i]
    base = np.power(2,i)
    base = base%m
    base = (base*num)%m

    ans += base
    ans = ans%m

# print(buf)
print(ans)



