#include #include #include #include #include #include #include #include using namespace std; int p = 1000000007; #define int long long #define vel vector #define vvel vector #define rep(i,n) for(long long i=0;i #define V vector #define Endl endl #define veb vector #define sq(a) (a)*(a) #define rev(s) reverse(s.begin(),s.end()) #define end_program(s) cout << s < q; q.push(mid1); while (!q.empty()) { int st = q.front(); q.pop(); rep(i, way[st].size()) { int to = way[st][i]; if (dist[to] == -1) { dist[to] = dist[st] + 1; q.push(to); } } } return dist; } pin most_far(int now, int n, vvel &way) { vel dist1 = dis(now, way); pin ans = mkp(-1, 0); rep(i, n) { if (dist1[i] > ans.first) { ans = mkp(dist1[i], i); } } return ans; } int gcd(int a, int b) { a = abs(a); b = abs(b); if (a < b) { swap(a, b); } if (b == 0) { return a; } return gcd(b, a%b); } int per(int a, int b) { int ans = a % b; if (ans < 0) { ans += b; } return ans; } V uni(V &v) { sor(v); V ans(1, v[0]); for (int i = 1; i < v.size(); i++) { if (v[i] != v[i-1]) { ans.push_back(v[i]); } } v = ans; return v; } int n; int ask(int a, int b) { a++; b++; if (a > n) { return b; } if (b > n) { return a; } cout << "? " << a << " " << b<> ans; return ans-1; } bool win_m(int a, int b) { return ask(a, b) == a; } signed main() { cin >> n; if (n % 2 == 1) { n++; } vvel ans(n / 2, vel(2)); rep(i, n) { ans[i / 2][i % 2] = i; } rep(i, n / 2) { if (ask(ans[i][0], ans[i][1]) == ans[i][1]) { swap(ans[i][0], ans[i][1]); } } while (ans.size() > 1) { vvel qans(ans.size()/2,vel(2)); rep(i, ans.size() / 2) { qans[i][0] = ask(ans[2 * i][0], ans[2 * i + 1][0]); if (qans[i][0]==ans[2 * i][0]) { ans[2 * i] = { ans[2 * i][1] }; } else { ans[2 * i + 1] = { ans[2 * i + 1][1] }; } qans[i][1] = ask(ans[2 * i][0], ans[2 * i + 1][0]); } if (ans.size() % 2 == 1) { qans.push_back(ans[ans.size() - 1]); } ans = qans; } cout << "! " << ans[0][1]+1 << flush; return 0; }