N = gets.to_i @w_list = gets.chomp.split.map(&:to_i) @half = 0 @dp = Array.new(10001, false) def main total = @w_list.inject(:+) return "impossible" if total & 1 == 1 @half = total >> 1 @dp[0] = true @w_list.each do |w| (@dp.size - 1).downto(0) do |i| @dp[i+w] = true if @dp[i] end end return @dp[@half] ? "possible" : "impossible" end puts main()