def main():
  N = int(input())
  A = list(map(int, input().split()))
  MOD = 10 ** 9 + 7
  ones = [sum(1 for a in A if a&(1<<i)) for i in range(60)]
  res = 0
  for j in range(N):
    a = A[j]
    for i in range(60):
      if (a >> i) & 1 == 0:
        res += ones[i] * ((2 ** i)%MOD)
      else:
        res += (N-ones[i]-j) * ((2 ** i)%MOD)
        ones[i] -= 1
      res %= MOD
  
  print(res)
if __name__ == "__main__":
    main()