import numpy as np
MOD = 10 ** 9 + 7
N = int(input())
A = list(map(int,input().split()))
cnt = []
A = np.array(A)
for _ in range(60):
    ad = A % 2
    cnt.append(np.sum(ad))
    A = A // 2
ans = 0
for i in range(60):
    num0 = N - cnt[i]
    num1 = cnt[i]
    ans += ((N * (N - 1) // 2) - (num0 * (num0 - 1) // 2) - (num1 * (num1 - 1) // 2)) * (2 ** i)
print(ans % MOD)