output_description: Print the maximum possible number of times the operation can be performed.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      S
attempt: # _*_ coding:utf-8 _*_
  #  Atcoder_Grand_Contest029-B
  #  https://agc029.contest.atcoder.jp/tasks/agc029_b
  from collections import Counter
  
  
  def maxCountPair(n_ballCount, a_ballDatas):
      a_ballDatas.sort(reverse=True)
      ballDictBox = Counter(a_ballDatas)
      ballCountRange = range(0, n_ballCount)
      pairCount = 0
      for i in ballCountRange:
          getBallNumber = a_ballDatas[i]
          getBallNumberBin = getBallNumber.bit_length()
          nextTwoPower = 2**getBallNumberBin
          diffNumber = nextTwoPower - getBallNumber
          if 1 <= ballDictBox[diffNumber]:
              if getBallNumber != diffNumber:
                  pairCount = pairCount + 1
                  ballDictBox[getBallNumber] = ballDictBox[getBallNumber] - 1
                  ballDictBox[diffNumber] = ballDictBox[diffNumber] - 1
              else:
                  if 2 <= ballDictBox[diffNumber]:
                      pairCount = pairCount + 1
                      ballDictBox[diffNumber] = ballDictBox[diffNumber] - 2
      answer = pairCount
      return answer
  
  
  if __name__ == "__main__":
      n_ballCount = int(input())
      a_ballDatas = list((map(int, input().split(" "))))
      solution = maxCountPair(n_ballCount, a_ballDatas)
      print(solution)
  
problem_description: Statement
  
  There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc
  with a black side and a white side.) The state of each piece is represented by
  a string S of length N. If S_i=`B`, the i-th piece from the left is showing
  black; If S_i=`W`, the i-th piece from the left is showing white.
  
  Consider performing the following operation:
  
    * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black.
  
  Find the maximum possible number of times this operation can be performed.
samples: [{"input": "BBW", "output": "2\n    \n\nThe operation can be performed twice, as follows:\n\n  * Flip the second and third pieces from the left.\n  * Flip the first and second pieces from the left.\n\n* * *"}, {"input": "BWBWBW", "output": "6"}]