def f(n, weights) sum = weights.inject(0, :+) return false if sum.odd? dp = {} dp[0] = true weights.each{|weight| (sum/2).downto(0){|w| dp[w] ||= dp[w-weight] } } dp[sum/2] end N = gets.to_i W = gets.split.take(N).map(&:to_i).sort puts f(N, W) ? :possible : :impossible