n = int(input())
a = list(map(int, input().split()))

MOD = 1000000007

ans = 0

for i in range(62):
    b = 1 << i
    # v = [[0 for i in range(n + 1)] for j in range(2)]
    v = [[0 for i in range(2)] for j in range(n + 1)]
    
    for j in reversed(range(n)):
        x = (a[j] >> i) & 1
        v[j][x] = v[j+1][x] + 1
        v[j][1-x] = v[j+1][1-x]
        
    t = 0
    for j in range(n-1):
        x = (a[j] >> i) & 1
        t += v[j+1][1-x]
        t %= MOD
           
    y = t * b
    y %= MOD
    ans += y
    ans %= MOD
    
print(ans)