N = int(input())

A = list(map(int, input().split()))
max_leng = len(bin(max(A))) - 2
A = list(map(bin, A))
A_processed = []

for a in A:
    a = a[2:]
    while len(a) < max_leng:
        a = '0' + a
    A_processed.append(a)

res = 0

for i in range(max_leng):
    num_0 = 0
    for a in A_processed:
        if a[max_leng - 1 - i] == '0':
            num_0 += 1
    res += 2**i * num_0 * (N - num_0)
    res = res % 1000000007

print(res)