#include #include using namespace std; using namespace atcoder; using ll = long long; using pl = std::pair; using mint = atcoder::modint1000000007; //using mint = atcoder::modint998244353; #define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++) #define all(v) (v).begin(), (v).end() #define dump(var) do{ if(debug::enable) { std::cerr << #var << " : "; debug::print(var); } } while(0); constexpr int di[4] = {1, -1, 0, 0}; constexpr int dj[4] = {0, 0, 1, -1}; constexpr long long inf = 1LL<<60; template inline void chmax(T &a, T b) { a = std::max(a, b); }; template inline void chmin(T &a, T b) { a = std::min(a, b); }; template void vprint(const std::vector& v) { for(int i = 0; i < v.size(); i++) { std::cout << v[i] << (i == v.size()-1 ? "\n" : " "); } } template void vprintln(const std::vector& v) { for(int i = 0; i < v.size(); i++) { std::cout << v[i] << "\n"; } } template void vprint(const std::vector>& v) { for(int i = 0; i < v.size(); i++) { std::cout << v[i].val() << (i == v.size()-1 ? "\n" : " "); } } template void vprintln(const std::vector>& v) { for(int i = 0; i < v.size(); i++) { std::cout << v[i].val() << "\n"; } } namespace debug { #if defined(ONLINE_JUDGE) const bool enable = false; #else const bool enable = true; #endif template void push(const T& e) { std::cerr << e; } template void push(const atcoder::static_modint& e) { std::cerr << e.val(); } template void push(const std::pair& e) { std::cerr << "("; push(e.first); std::cerr << ","; push(e.second); std::cerr << ")"; } template void push(const std::tuple& e) { std::cerr << "("; push(get<0>(e)); std::cerr << ","; push(get<1>(e)); std::cerr << ","; push(get<2>(e)); std::cerr << ")"; } template void print(const T& e) { push(e); std::cerr << "\n"; } template void print(const std::vector& v) { for(int i = 0; i < v.size(); i++) { push(v[i]); std::cerr << " "; } std::cerr << "\n"; } template void print(const std::vector>& v) { std::cerr << "\n"; for(int i = 0; i < v.size(); i++) { std::cerr << i << ": "; print(v[i]); } } }; ll query(ll k) { cout << "? " << k << endl << flush; ll res; cin >> res; ll plus = res, neg = k - res; return plus - neg; } void answer(ll l, ll r) { cout << "! " << l << " " << r << endl << flush; } void solve() { ll n; cin >> n; ll l = 1, r = n-1; ll vl = query(l); ll vr = query(r); dump(vl); dump(vr); if(vl == vr) { answer(l+1, r); return; } while(r - l > 1) { ll m = (l + r) / 2; ll vm = query(m); if(vm == 0) { if(m >= n / 2) answer(1, m); else answer(m+1, n); return; } if(vl < 0) { if(vm < 0) l = m; else r = m; } else { if(vm > 0) l = m; else r = m; } } assert(false); } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); solve(); return 0; }