output_description: Print the answer.
  
  * * *
input_description: The input is given from Standard Input in the following format:
  
      
      
      N
      a_1
      :
      a_N
attempt: def solve(n, a):
      """
      References
      ----------
      [1]. 足跡-sokuseki-, CODE FESTIVAL 2016 Grand Final C - Cheating Nim, http://wk1080id.hatenablog.com/entry/2018/08/17/234023
      [2]. iroiro, CODE FESTIVAL 2016 Grand Final C - Cheating Nim, http://xxxasdfghjk999.hatenablog.jp/entry/2018/11/01/235259
      [3]. Yang33, 競プロにおけるNim、Grundy数とNimK, http://yang33-kassa.hatenablog.com/entry/2017/12/21/202812
      """
      x = 0
      for i in range(n):
          x ^= a[i]
      b = [a[i] ^ (a[i] - 1) for i in range(n)]
      mapping = {2**k - 1: 0 for k in range(31)}
      for y in b:
          mapping[y] += 1
      ans = 0
      for k in range(30, 0, -1):
          y = 2**k - 1
          z = 2 ** (k - 1)
          if (x & z) > 0 and (mapping[y] > 0):
              ans += 1
              mapping[y] -= 1
              x ^= y
      return ans if x == 0 else -1
  
  
  n = int(input())
  a = [int(input()) for i in range(n)]
  print(solve(n, a))
  
problem_description: Statement
  
  A cheetah and a cheater are going to play the game of Nim. In this game they
  use N piles of stones. Initially the i-th pile contains a_i stones. The
  players take turns alternately, and the cheetah plays first. In each turn, the
  player chooses one of the piles, and takes one or more stones from the pile.
  The player who can't make a move loses.
  
  However, before the game starts, the cheater wants to cheat a bit to make sure
  that he can win regardless of the moves by the cheetah. From each pile, the
  cheater takes zero or one stone and eats it before the game. In case there are
  multiple ways to guarantee his winning, he wants to minimize the number of
  stones he eats.
  
  Compute the number of stones the cheater will eat. In case there is no way for
  the cheater to win the game even with the cheating, print `-1` instead.
samples: [{"input": "3\n    2\n    3\n    4", "output": "3\n    \n\nThe only way for the cheater to win the game is to take stones from all piles\nand eat them.\n\n* * *"}, {"input": "3\n    100\n    100\n    100", "output": "-1"}]