N = gets.to_i @w_list = gets.chomp.split.map(&:to_i) @half = 0 @dp = Array.new(100, Array.new(10001, true)) def solve(idx, total) return false if idx >= N || total > @half return @dp[idx][total] if @dp[idx][total] == false return true if total == @half return true if solve(idx + 1, total) || solve(idx + 1, total + @w_list[idx]) return @dp[idx][total] = false end def main total = @w_list.inject(:+) return "impossible" if total & 1 == 1 @half = total >> 1 @w_list.sort! return solve(0, 0) ? "possible" : "impossible" end puts main()