def recursive(left, right, remain, weights) if remain == 0 return left == right end if (left - right).abs > remain return false end w = weights.shift result_left = recursive(left + w, right, remain - w, weights) if result_left weights.unshift(w) return result_left end result_right = recursive(left, right + w, remain - w, weights) weights.unshift(w) return result_right end N = gets.to_i weights = gets.split.map(&:to_i) remain = weights.sum result = recursive(0, 0, remain, weights) if result puts "possible" else puts "impossible" end