n = gets.to_i d = gets.split.map(&:to_i) x, y = gets.split.map(&:to_i) if x == 0 && y == 0 p 0 elsif d.include?(x.abs + y.abs) p 1 elsif d.max * 2 >= (x.abs + y.abs) p 2 else p -1 end