
M = 10 ** 9 + 7
X = 60

N = int(input())

A_list = list(map(int, input().split()))

total = 0
for i in range(X):
	counts = [0] * (N + 1)
	for j in range(N - 1, -1, -1):
		counts[j] = counts[j + 1] + ((A_list[j] >> i) & 1)
	count = 0
	for j in range(N - 1):
		if ((A_list[j] >> i) & 1) == 1:
			count += N - j - counts[j]
		else:
			count += counts[j]
	total = (total + (1 << i) * count) % M

print(total)
