#include #include #include #include #include #include #include using namespace std; #define int long long #define rep(i,n) for(int i = 0; i < (n); i++) #define endl "\n" const long long INF = (long long)1e18; const long long MOD = (long long)1e9 + 7; string yn(bool f){return f?"Yes":"No";} string YN(bool f){return f?"YES":"NO";} #define MAX signed main(){ // cin.tie(0); // ios::sync_with_stdio(false); // cout<,int>> x; list lst, lst2; cin>>N; for(int i = 1; i <= N; i++){ lst.push_back(i); } while(lst.size() != 1){ for(list::iterator itr = ++lst.begin(); itr != lst.end(); itr++){ auto itr1 = --itr; itr++; int ans; cout<<"? "<<*itr1<<" "<<*itr<>ans; x.push_back(make_pair(make_pair(*itr1, *itr), ans)); if(*itr == ans) { lst.erase(itr1); if(++itr == lst.end()) break; } else { itr = lst.erase(itr); if(itr == lst.end()) break; } } } win = *lst.begin(); for(int i = 0; i < x.size(); i++){ if(x[i].second == win) lst2.push_back(x[i].first.first == win ? x[i].first.second : x[i].first.first); } while(lst2.size() != 1){ for(list::iterator itr = ++lst2.begin(); itr != lst2.end(); itr++){ auto itr1 = --itr; itr++; int ans; cout<<"? "<<*itr1<<" "<<*itr<>ans; if(*itr == ans) { lst2.erase(itr1); if(++itr == lst2.end()) break; } else { itr = lst2.erase(itr); if(itr == lst2.end()) break; } } } cout<<"! "<<*lst2.begin()<