n = int(input())
A = list(map(int, input().split()))
one = [0 for _ in range(60)]

for a in A:
    for i in range(60):
        if a & 1 << i:
            one[i] += 1
ans = 0
for j, a in enumerate(A):
    n -= 1
    if n == 0:
        break
    for i in range(60):
        if a & 1 << i:
            one[i] -= 1
    # print(one)

    for i in range(60):
        if a & 1 << i:
            ans += (1 << i) * (n - one[i])
        else:
            ans += (1 << i) * one[i]


print(ans % 1000000007)
