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

p = len(format(max(A), 'b'))
digit = '0' + str(p) + 'b'
#S = list(map(format, A, digit))

r = [0] * p
for a in A:
  s = format(a, digit)
  for j in range(p):
    r[j] += int(s[j])

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

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