N = int(input())
A = list(map(int, input().split()))  # O(N)
p = len(format(max(A), 'b')) # O(N)
digit = ['0' + str(p) + 'b'] * N
S = list(map(format, A, digit))  # O(N)

r = [0] * p
for s in S:
  for j in range(p):
    r[j] += int(s[j])

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

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