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

  result = 0
  for b in range(60):
    B = 1 << b
    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]

    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 * B) % 1000000007
  print(result)
main()
