from sys import stdin

input = stdin.readline

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

cnt = [0] * 65
ans = 0
for p, x in enumerate(a):
    for i in range(61):
        pos = (x >> i) & 1
        if pos:
            ans += (1 << i) * (p - cnt[i])
        else:
            ans += (1 << i) * cnt[i]
        # print(x, i, pos, ans, cnt[:3])
        ans %= mod
        cnt[i] += pos

print(ans % mod)
