#include #define all(vec) vec.begin(), vec.end() using namespace std; using ll = long long; using P = pair; constexpr ll INF = (1LL << 30) - 1LL; constexpr ll LINF = (1LL << 60) - 1LL; constexpr double eps = 1e-9; constexpr ll MOD = 1000000007LL; template bool chmin(T& a, T b) { if(a > b) { a = b; return true; } return false; }; template bool chmax(T& a, T b) { if(a < b) { a = b; return true; } return false; }; template ostream& operator<<(ostream& os, vector v) { for(int i = 0; i < v.size(); i++) { os << v[i] << (i + 1 == v.size() ? "\n" : " "); } return os; } template vector make_v(size_t a) { return vector(a); } template auto make_v(size_t a, Ts... ts) { return vector(ts...))>(a, make_v(ts...)); } template typename enable_if::value == 0>::type fill_v(T& t, const V& v) { t = v; } template typename enable_if::value != 0>::type fill_v(T& t, const V& v) { for(auto& e : t) { fill_v(e, v); } }; int ask(int x, int y) { cout << "? " << x << " " << y << endl; int s; cin >> s; return s; } int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vector v; vector> g(n + 10); for(int i = 1; i <= n; i++) { v.push_back(i); } while(v.size() > 1) { int m = v.size(); vector v2; for(int i = 0; i < m / 2; i++) { v2.push_back(ask(v[2 * i], v[2 * i + 1])); g[v[2 * i]].push_back(v[2 * i + 1]); g[v[2 * i + 1]].push_back(v[2 * i]); } if(m % 2) { v2.push_back(v[m - 1]); } v = v2; } int t = v[0]; v.clear(); for(auto e : g[t]) { v.push_back(e); } while(v.size() > 1) { int m = v.size(); vector v2; for(int i = 0; i < m / 2; i++) { v2.push_back(ask(v[2 * i], v[2 * i + 1])); g[v[2 * i]].push_back(v[2 * i + 1]); g[v[2 * i + 1]].push_back(v[2 * i]); } if(m % 2) { v2.push_back(v[m - 1]); } v = v2; } cout << "! " << v[0] << endl; }