import numpy as np
n = int(input())
mod = 10 ** 9 + 7
a = [list(bin(int(i))[2:].zfill(60)) for i in input().split()]
a = np.array(a)
x = a.T
x = x.tolist()
#print(x)
ans = 0
for i in range(60):
    y = x[i].count('0')
    z = x[i].count('1')
    tmp = ( (n * (n - 1) // 2) - (y * (y - 1) // 2) - (z * (z - 1) // 2) ) % mod
    tmp2 = 1
    for j in range(60 - i - 1):
        tmp2 = tmp2 * 2 % mod
    #print(tmp,tmp2)
    
    ans = (ans + tmp2 * tmp) % mod
print(ans)
    
    