#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 Q=0; int query(int a,int b){ assert(Q<=335); Q++; cout<<"? "<>res;res--; return res; } vector cut_half(vector v){ vector ret; int n=(int)v.size(); rep(i,n/2) ret.push_back(query(v[2*i],v[2*i+1])); if(n&1) ret.push_back(v.back()); return ret; } void solve_all(vector w){ int n=(int)w.size(); int sz=1; while(sz> v(sz*2); rep(i,n) v[i+sz].push_back(w[i]); auto f=[&](int l,int r){ vector ret; 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(win==v[l][i]) i++; else j++; } ret.push_back(win); } return ret; }; for(int k=sz-1;k>0;k--) v[k]=f(2*k,2*k+1); cout<<"! "<>n; vector ord(n); iota(ALL(ord),0); mt19937 mt(chrono::steady_clock::now().time_since_epoch().count()); shuffle(ALL(ord),mt); if(n>150) ord=cut_half(ord); solve_all(ord); return 0; }