import numpy as np

N = int(input())
A = list(map(int, input().split()))

MOD = 10**9 + 7

ans = 0
M = len(bin(max(A))[2:])

B = [bin(A[i])[2:].zfill(M) for i in range(N)]
bin1 = [0 for _ in range(M)]

for d in range(M):
    bin1[d] = sum([int(B[i][d]) for i in range(N)])

for d in range(M):
    ans += pow(2, d, MOD) * bin1[-(d+1)] * (N - bin1[-(d+1)])
    ans %= MOD

print(ans)
