output_description: Print the maximum possible number of pairs such that the sum of the integers
  written on each pair of balls is a power of 2.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      A_1 A_2 ... A_N
attempt: import collections
  
  N = int(input())
  A = list(map(int, input().split()))
  l = []
  c = collections.Counter(A)
  values = list(c.values())  # aのCollectionのvalue値のリスト(n_1こ、n_2こ…)
  key = list(c.keys())  # 先のvalue値に相当する要素のリスト(要素1,要素2,…)
  for i in range(len(key)):
      l.append([key[i], values[i]])  # lは[要素i,n_i]の情報を詰めたmatrix
  # print(l)
  n = len(l)
  ans = 0
  cnt = 0
  d = dict(l)
  # print(d)
  ans = 0
  for i in range(31, 0, -1):
      piv = pow(2, i)
      cnt = 0
      for j in range(n):
          val1 = d.get(l[j][0])
          val2 = d.get(piv - l[j][0])
          if (val1 != None) and (val2 != None):
              add = min(val1, val2)
              if l[j][0] == piv - l[j][0]:
                  add = add // 2
                  ans = ans + add
                  add = add * 2
              else:
                  ans = ans + add
              d[l[j][0]] = val1 - add
              d[piv - l[j][0]] = val2 - add
          # print(d)
          # input()
      # ans=ans+(cnt-c[piv//2])//2
      # print(i,ans)
  print(ans)
  
problem_description: Statement
  
  Takahashi has N balls with positive integers written on them. The integer
  written on the i-th ball is A_i. He would like to form some number of pairs
  such that the sum of the integers written on each pair of balls is a power of
  2. Note that a ball cannot belong to multiple pairs. Find the maximum possible
  number of pairs that can be formed.
  
  Here, a positive integer is said to be a power of 2 when it can be written as
  2^t using some non-negative integer t.
samples: [{"input": "3\n    1 2 3", "output": "1\n    \n\nWe can form one pair whose sum of the written numbers is 4 by pairing the\nfirst and third balls. Note that we cannot pair the second ball with itself.\n\n* * *"}, {"input": "5\n    3 11 14 5 13", "output": "2"}]