local function query(num) io.write("? " .. num .. "\n") io.flush() local ret = io.read("*l") return tonumber(ret) end local function ans(l, r) io.write("! " .. l .. " " .. r .. "\n") io.flush() os.exit() end local n = io.read("*n", "*l") local left, right = 2, n - 1 local lv = query(left) local rv = query(right) if lv == rv then ans(left, right) end local hn = math.floor(n / 2) for i = 1, 18 do local mid = math.floor((left + right) / 2) local mv = query(mid) if mv == 0 then if hn <= mid then ans(1, mid) else ans(mid, n) end else if mv * lv < 0 then right = mid else left = mid end end end