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: ball_num = int(input())
  num_data = list(map(int, input().split()))
  
  ans = 0
  
  
  def check_beki(num1, num2):
      data = num1 + num2
      while 1:
          data1 = data % 2
          data = int(data / 2)
          if data1 == 1:
              return 0
          elif num1 + num2 >= 1 and data == 1:
              return 1
  
  
  def check_ans(ans_list, tasu_flg):
      global ans
      ans_kari = 0
      for i in range(len(ans_list)):
          if check_beki(ans_list[i], 0) and tasu_flg[i] == 1:
              ans_kari += 1
      if ans_kari > ans:
          ans = ans_kari
  
  
  def check(index, ans_list_ori, tasu_flg_ori):
      global ball_num, num_data
      ans_list = ans_list_ori.copy()
      tasu_flg = tasu_flg_ori.copy()
  
      # if len(ans_list) >= tree_num:
      #     return
  
      # print(check_beki(3, 5))
  
      if index < ball_num:
          for j in range(len(ans_list)):
              # print(ans_list[j], num_data[index])
              if check_beki(ans_list[j], num_data[index]) and tasu_flg[j] == 0:
                  # print('yyy')
                  ans_list[j] += num_data[index]
                  tasu_flg[j] = 1
                  check(index + 1, ans_list, tasu_flg)
                  tasu_flg[j] = 0
                  ans_list[j] -= num_data[index]
              # 新しく木を使う場合
              ans_list.append(num_data[index])
              tasu_flg.append(0)
              check(index + 1, ans_list, tasu_flg)
              tasu_flg.pop(-1)
              ans_list.pop(-1)
      else:
          # 以前よりも最少の気で作れたら最小値の更新
          check_ans(ans_list, tasu_flg)
  
  
  def main():
      global num_data
      check(1, [num_data[0]], [0])
  
      print(ans)
  
  
  if __name__ == "__main__":
      main()
  
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"}]