#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
pow2 = [1]
for i in range(59):
    pow2.append(pow2[-1]*2)

for i in range(60):
    rui = [0]
    old = 0
    for b in B:
        if b[i] == "1":
            old+=1
            rui.append(old)
        else:
            rui.append(old)
    del rui[0]
    
    N1 = rui[N-1]
    kari = 0
    for j,(b,r) in enumerate(zip(B,rui)):
        if b[i] == "1":
            kari+=(N-j-1)-(N1-r)
        else:
            kari+=(N1-r)
    ans+=kari*pow2[59-i]
    ans%=mod
print(ans)

