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

  num_ones = [0 for x in range(60)]
  powers_of_two = [1]
  for i in range(1,60):
    powers_of_two.append((powers_of_two[-1] * 2) % 1000000007)
  
  ans = 0
  for i in range(N-1,-1,-1):
    for j in range(60):
      if A[i] & 1 == 0:
        ans = (ans + powers_of_two[j] * num_ones[j]) % 1000000007
      else:
        ans = (ans + powers_of_two[j] * (N - i - 1 - num_ones[j])) % 1000000007
        num_ones[j] += 1
      A[i] >>= 1
  print(ans)
        
d()
