import numpy as np

MOD = 10**9 + 7
def solve(n, a, p=64):
    s = np.zeros(p, dtype=int)
    a = a[::-1]
    res = 0
    for i in range(n):
        mask = bin(a[i])[2:].zfill(p)[::-1]
        mask = np.asarray(list(map(int, mask)), dtype=int)
        s += mask
        for j in range(p):
            if mask[j] == 1:
                res += (i - int(s[j]) + 1) * (2**j)
            else:
                res += int(s[j]) * (2**j)
        res %= MOD
    return res % MOD

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