loop do
  n = gets.to_i
  break if n == 0
  arr = gets.split(' ').map(&:to_i)
  dp = Array.new(n-1) { Array.new(21, 0) }
  answer = arr[n-1]
  dp[0][arr[0]] = 1

  1.upto(n-2) do |i|
    0.upto(20) do |j|
      next if dp[i-1][j] == 0
      add = j + arr[i]
      sub = j - arr[i]

      dp[i][add] += dp[i-1][j] if add <= 20
      dp[i][sub] += dp[i-1][j] if sub >= 0
    end
  end

  puts dp[n-2][answer]
end