STDOUT.sync = true N = gets.to_i (N / 2).times do |i| x = i y = N - 1 - i puts "? #{x} #{y}" z = gets.to_i if z == x puts "! #{y}" exit elsif z == y puts "! #{x}" exit end end puts "! #{N / 2}"