def dfs(i, w_sum) if w_sum == @w.inject(:+) / 2 puts "possible" exit end if i >= @w.length return end dfs(i + 1, w_sum) dfs(i + 1, w_sum + @w[i]) end n = gets.strip.to_i @w = gets.strip.split(' ').map(&:to_i) dfs(0, 0) puts "impossible"