n = gets.to_i ds = gets.chomp.split.map(&:to_i).sort.reverse x, y = gets.chomp.split.map(&:to_i) r = x.abs + y.abs if ds.any? {|d| d == r} p 1 elsif r.even? d_max = ds[0] if r <= d_max + d_max p 2 else p -1 end else es = ds.select(&:even?).sort.reverse os = ds.select(&:odd?).sort.reverse if es.size.zero? or os.size.zero? p -1 exit end e_max = es[0] o_max = os[0] if es.any? {|d| d - o_max <= r and r <= d + o_max} p 2 elsif os.any? {|d| d - e_max <= r and r <= d + e_max} p 2 else p -1 end end