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

  num_ones = [0 for x in range(60)]
  for i in range(N):
    k = A[i]
    cnt = 0
    while k:
      num_ones[cnt] += k % 2
      cnt += 1
      k //= 2
  
  ans = 0
  for i in range(N-1):
    for j in range(60):
      if A[i] % 2 == 0:
        ans = (ans + (1 << j) * num_ones[j]) % 1000000007
      else:
        num_ones[j] -= 1
        ans = (ans + (1 << j) * (N - i - 1 - num_ones[j])) % 1000000007
      A[i] //= 2
  print(ans)
        
d()