n = int(input())
a = list(map(int, input().split()))

max_a = max(a)
msb = -1
for i in range(60 + 1):
    if max_a < 2 ** i:
        msb = i

assert msb >= 0
msb += 1

t = [[0 for _ in range(msb) ] for _ in range(n)]

for s in range(msb):
    t[0][s] = 1 if a[0] & (1 << s) > 0 else 0

for i in range(1, n):
    for s in range(msb):
        t[i][s] = t[i - 1][s] + (1 if a[i] & (1 << s) > 0 else 0)


ans = 0
for i in range(n - 1):
    for s in range(msb):
        stand = t[-1][s] - t[i][s]
        no_stand = (n - (i + 1)) - stand
        if a[i] & (1 << s) == 0:
            ans += (1 << s) * stand
            ans %= (10 ** 9 + 7)
        else:
            ans += (1 << s) * no_stand
            ans %= (10 ** 9 + 7)
print(ans)
