mod = 10**9+7

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

N = int(input())
A = list(map(int, input().split()))
A_max = max(A)
L = len(Base_10_to_n(A_max, 2))
bit_cnt = [0] * L
wa = 0
for i in range(1,N):
	tmp = A[0] ^ A[i]
	wa += tmp
	wa %= mod
	tmp_bit = Base_10_to_n(tmp,2).rjust(L,"0")
	for j in range(L):
		if tmp_bit[j] == "1":
			bit_cnt[j] += 1
add = [0] * L
for i in range(1,N):
	tmp = A[0]^A[i]
	tmp_bit = Base_10_to_n(tmp,2).rjust(L,"0")
	for j in range(L):
		if tmp_bit[j] == "1":
			add[j] += (N-bit_cnt[j]*2)

wa *= N
wa %= mod

for i in range(L):
	tmp = add[i]*(2**(L-1-i))
	if tmp < 0:
		tmp *= (-1)
		tmp %= mod
		tmp = mod - tmp

	wa += tmp
	wa %= mod

wa *= pow(2,mod-2,mod)
wa %= mod

print(wa)