N = gets.to_i def send_query(k) STDOUT.puts("? #{k}") STDOUT.flush s = gets.to_i rs = k - s s - rs end s_1 = send_query(1) s_n_1 = send_query(N - 1) if s_1 == s_n_1 puts "! #{2} #{N - 1}" exit end l = 2 r = N - 1 18.times do k = (l + r) / 2 s = send_query(k) if s == 0 if k < N / 2 puts "! #{k + 1} #{N}" else puts "! 1 #{k}" end exit elsif s_1 * s < 0 r = k elsif s_1 * s > 0 l = k elsif s_n_1 * s < 0 l = k elsif s_n_1 * x > 0 r = k end end