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):
    #print("d", d)
    res = 0
    for i in range(N):
        bit = bin(A[i])[2:].zfill(M)[-d]
        #print(bin(A[i])[2:].zfill(M), bit)
        res += int(bit)
    #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)
