#include #define rep(i, n) for(i = 0; i < n; i++) using namespace std; int query(int x, int y, int n) { if (y < 0 || y >= n) return x; if (x < 0 || x >= n) return y; cout << "? " << x + 1 << " " << y + 1 << endl; int ret; cin >> ret; return ret - 1; } const int DEPTH = 9; int seg[1 << (DEPTH + 1)]; void init(int n) { int i; rep(i, (1 << (DEPTH + 1))) seg[i] = -1; rep(i, n) seg[(1 << DEPTH) - 1 + i] = i; } int construct(int n, int a = 0, int b = (1 << DEPTH), int id = 0) { if (b - a == 1) { return seg[id]; } int u = construct(n, a, (a + b) / 2, id * 2 + 1); int v = construct(n, a, (a + b) / 2, id * 2 + 2); int res = query(u, v, n); seg[id] = res; return res; } int update(int pos, int val, int n) { pos += (1 << DEPTH) - 1; seg[pos] = val; while (pos > 0) { pos = (pos - 1) / 2; int res = query(seg[pos * 2 + 1], seg[pos * 2 + 2], n); seg[pos] = res; } return seg[0]; } int main() { int n; cin >> n; init(n); int winner = construct(n); int ans = update(winner, -1, n); cout << "! " << ans + 1 << endl; return 0; }