MOD = 10**9 + 7
def solve(n, a, p=64):
    s = [0] * p
    a = a[::-1]
    res = 0
    for i in range(n):
        mask = bin(a[i])[2:][::-1]
        c = [0] * p
        for j, b in enumerate(map(int, mask)):
            s[j] += b
            c[j] = b
        for j in range(p):
            if c[j] == 1:
                res += (i - s[j] + 1) * (2**j)
            else:
                res += s[j] * (2**j)
    return res % MOD

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