#include using namespace std; #define ALL(x) begin(x),end(x) #define rep(i,n) for(int i=0;i<(n);i++) #define debug(v) cout<<#v<<":";for(auto x:v){cout<bool chmax(T &a,const T &b){if(abool chmin(T &a,const T &b){if(b ostream &operator<<(ostream &os,const vector&v){ for(int i=0;i<(int)v.size();i++) os< istream &operator>>(istream &is,vector&v){ for(T &x:v)is>>x; return is; } int query(int a,int b){ cout<<"? "<>res;res--; return res; } signed main(){ int n;cin>>n; using P=pair; priority_queue,greater

> que; vector> v(n); rep(i,n){ v[i].push_back(i); que.emplace(1,i); } while(que.size()>1){ auto lp=que.top();que.pop(); auto rp=que.top();que.pop(); int l=lp.second,r=rp.second; vector nx; for(int i=0,j=0;i=2) break; int win=-1; if(i==v[l].size()) win=v[r][j++]; else if(j==v[r].size()) win=v[l][i++]; else{ win=query(v[l][i],v[r][j]); if(v[l][i]==win) i++; else j++; } nx.push_back(win); } v[l]=nx; que.emplace(v[l].size(),l); } cout<<"! "<<(v[0][1]+1)<