import sys, math
from pprint import pprint
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N = ri()
A = rl()

b = [0] * 60

def count(a, b):
	i = len(b)-1
	while a:
		b[i] += a % 2
		a //= 2
		i -= 1
	return i+1

def sum_xor(a, b, l):
	i = len(b)-1
	e = 1
	s = 0
	for i in reversed(range(len(b))):
		if a % 2 == 0:
			s += b[i] * e % mod
		else:
			s += (l-(b[i])) * e % mod
		a //= 2
		e = e * 2 % mod
		s = s % mod
	return s

ans = 0
for i in range(N):
	if i > 0:
		ans = (ans + sum_xor(A[i], b, i)) % mod
	count(A[i], b)
print(ans)