N = int(input())
A = sorted(list(map(int, input().split())))
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

L = len(Base_10_to_n(A[-1],2))

cnt = [0] * L
ans = 0
for i in range(1,N):
	tmp = A[0]^A[i]
	ans += tmp
	tt = Base_10_to_n(tmp,2).rjust(L,"0")
	for j in range(L):
		if tt[j] == "1":
			cnt[j] += 1
T= ans
ans %= mod

for i in range(1,N):
	TT = T
	tmp=0
	t = A[0]^A[i]
	tt = Base_10_to_n(t,2).rjust(L,"0")
	ttt = list(map(int, tt))
	for j in range(L):
		if ttt[j] == 1:
			tmp -= 2**(L-1-j) * cnt[j]
			tmp += 2**(L-1-j) * (N-cnt[j])
	TT += tmp
	ans += TT
	ans %= mod

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

print(ans)