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

MOD = 10**9 + 7

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

for d in range(1, M+1):
    res = 0
    res = sum([int(bin(A[i])[2:].zfill(M)[-d]) for i in range(N)])
    ans += pow(2, d-1, MOD) * res * (N-res)
    ans %= MOD

print(ans)
