import numpy as np
N = int(input())
As = list(map(int, input().split()))

def to_bit(n):
    res = np.zeros(60, dtype=int)
    for digit in range(59, -1, -1):
        res[digit] = n % 2
        n >>= 1
    return res

P = 1e9 + 7
nums = np.array([to_bit(a) for a in As])
num1 = nums.sum(axis=0)
num0 = N - num1

res = 0
for prod in num0 * num1:
    res <<= 1
    res += prod
    res = int(res % P)
print(res)