MOD = 10**9 + 7
n = int(input())
a = list(map(int, input().split()))

n_bit = max(a).bit_length()
ans = 0
bit = [0] * n_bit
for i in range(n):
    for j in range(n_bit):
        if (a[i] >> j) & 1:
            ans += (1 << j) * (i - bit[j])
        else:
            ans += (1 << j) * bit[j]
        ans %= MOD

        if (a[i] >> j) & 1:
            bit[j] += 1

print(ans)
