n = gets.to_i l = gets.to_s.chop.split(" ").map{|i|i.to_i} xy = gets.to_s.chop.split(" ").map{|i|i.to_i} x = xy[0] < 0 ? xy[0] * -1 : xy[0] y = xy[1] < 0 ? xy[1] * -1 : xy[1] sum = x+y step = -1 (l.size).times{|i| if l[i] == sum step = 1 break end (l.size-1-i).times{|j| if l[i] + l[i+j+1] == sum step = 2 break end } if step != -1 break end } puts step