#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):
    keta = 2**(59-i)
    bilist = []
    for b in B:
        bilist.append(b[i])
        
    brui = [0]
    for bi in bilist:
        bl = brui[-1]
        if bi == "1":
            bl+=1
        brui.append(bl)
        
    M = brui[-1]
    k = 0
    for j,b in enumerate(bilist):
        if b == "0":
            k+=(M-brui[j])
        else:
            k+=(N-M)-(j-brui[j])
            
    ans+=keta*k
    ans%=mod
    
print(ans)
        
    


