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

result = 0
for b in range(60):
  a = [(e >> b) & 1 for e in A]
  bs = [0] * N
  bs[N - 1] = a[N - 1]
  for i in range(N - 2, -1, -1):
    bs[i] = bs[i + 1] + a[i]

  t = 0
  for i in range(N - 1):
    if a[i] == 0:
      t += bs[i + 1]
    else:
      t += (N - (i + 1)) - bs[i + 1]
  result = (result + t * (1 << b)) % 1000000007
print(result)
