N = gets.to_i W = gets.split.map(&:to_i).sort! def f(n, ws) sum = 0; ws.each{ |w| sum += w } #puts " sum=#{sum}->#{sum/2}" return false if sum.odd? dp = {} dp[0] = true ws.each do | w | dpc = dp.clone dpc.keys.each do | d | dp[d+w] = dpc[d] end end #dp.sort.each{|k,v| puts "k=#{k}, v=#{v}"} return dp[sum/2] end puts f(N, W) ? 'possible' : 'impossible'