N = int(input())
A = list(map(int, input().split()))

p = len(format(max(A), 'b'))
digit = '0' + str(p) + 'b'

r = [0] * p
for i in range(N):
  tmp = format(A[i], digit)
  #print(tmp)
  for j in range(p):
    r[j] += int(tmp[j])

#print(r)
s = 0
for j in range(p):
  s += r[j] * (N - r[j]) * (2 ** (p-1-j))

print(s % (10**9 + 7))