N = int(input())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7
ones = [0] * 60
zeros = [0] * 60
for i in range(N):
  x = A[i]
  x = bin(x)[2:]
  x = x.zfill(60)
  for j in range(59, -1, -1):
    if x[j] == '0':
      zeros[j] += 1
    else:
      ones[j] += 1
# print(ones)
# print(zeros)

res = 0
for i in range(N):
  x = A[i]
  x = bin(x)[2:]
  x = x.zfill(60)
  for j in range(60):
    if x[-j - 1] == '0':
      res += ones[-j - 1] * 2 ** j
      res %= MOD
      zeros[-j - 1] -= 1
    else:
      res += zeros[-j - 1] * 2 ** j
      res %= MOD
      ones[-j - 1] -= 1
print(res)