import numpy as np
mod = 10**9+7
N = int(input())
A = list(map(int, input().split()))

def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out

A_max = max(A)
L = len(Base_10_to_n(A_max, 2))

all = N
bit = np.array([0]*L)
for i in range(N):
	tmp = Base_10_to_n(A[i],2).rjust(L,"0")
	for j in range(L):
		if tmp[j] == "1":
			bit[j] += 1

ans = np.array([0] * L, dtype="int64")
for i in range(N):
	tmp = Base_10_to_n(A[i],2).rjust(L,"0")
	for j in range(L):
		if tmp[j] == "0":
			ans[j] += bit[j]
		else:
			ans[j] += (all - bit[j])
			bit[j] -= 1

	all -= 1

a = 0
for i in range(L):
	ans[i] %= mod
	tmp = (2**(L-i-1)) % mod
	a += ans[i] * tmp
	a %= mod
print(a)