MOD = 10**9+7

N = int(input())
A = list(map(int,input().split()))
X = [0]*60
sumA = 0
for i in A:
    for j in range(60):
        if i >> j & 1 == 1:
            X[j] += 1
    sumA += i
ans = 0
for i in range(N):
    sumA -= A[i]
    ans += sumA
    for j in range(60):
        if A[i] >> j & 1 == 1:
            X[j] -= 1
            ans += ((2**j) * (N-i-1-X[j]*2))%MOD
    ans %= MOD

print(ans)