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

MOD = 10**9 + 7

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

bin1 = [0 for _ in range(M)]

for i in range(N):
    b = bin(A[i])[2:].zfill(M)
    for d in range(M):
        bin1[d] += int(b[d])

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

print(ans)
