#D
mod = 10**9+7
N = int(input())
A = list(map(int,input().split()))

B = []
for a in A:
    b = bin(a)
    b = b.lstrip("0b")
    while len(b) < 60:
        b = "0"+b
    B.append(b)
    
ans = 0
for i in range(60):
    rui = [0]
    for b in B:
        if b[i] == "1":
            rui.append(rui[-1]+1)
        else:
            rui.append(rui[-1])

    kari = 0
    for j,b in enumerate(B):
        if b[i] == "1":
            kari+=(N-j-1)-(rui[N]-rui[j+1])
        else:
            kari+=(rui[N]-rui[j+1])
    #print(kari)
    ans+=kari*(2**(59-i))
    ans%=mod
print(ans)

