import numpy as np
M = 10**9+7
N = int(input())
A = np.array(list(map(int,input().split())))
ans = 0

maxA = np.amax(A)
K = len(str(bin(maxA)))-2

for k in range(K):
    N1 = 0
    N1 = np.sum((A >> k) & 1)
    N0 = N-N1
    ans += (((1<<k)%M) *N0 *N1) % M
    ans %= M

print(ans)