module Memoizable
	def memoize(name)
		original = "__original_#{name}__"
		([Class, Module].include?(self.class) ? self : self.class).class_eval {
			alias_method(original, name)
			private(original)
			cache = {}
			define_method(name){|*args|
				cache[args] ||= send(original, *args)
			}
		}
	end 

	#def memoize(name)
	#	original = "__original_#{name}__"
	#	klass = ([Class, Module].include?(self.class) ? self : self.class)
	#	klass.class_eval <<-"EOS"
	#		alias_method('#{original}', '#{name}')
	#		private('#{original}')
	#		@@cache_for_#{name} = {}
	#		def #{name}(*args)
	#			@@cache_for_#{name}[args] ||= send('#{original}', *args)
	#		end
	#	EOS
	#end 
end

include Memoizable

$n = gets.to_i
$a = gets.split.map &:to_i

def f(left, i)
	if i == $n-1
		return left == $a[i] ? 1 : 0
	end
	sum = 0
	sum += f(left - $a[i], i+1) if left >= $a[i]
	sum += f(left + $a[i], i+1) if left + $a[i] <= 20
	sum
end

memoize :f

p f($a[0], 1)