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

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