#include using namespace std; #define rep(i, x, limit) for (long long i = (long long)x; i < (long long)limit; i++) #define REP(i, x, limit) for (long long i = (long long)x; i <= (long long)limit; i++) #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define el '\n' #define spa " " #define Yes cout << "Yes" << el #define No cout << "No" << el #define YES cout << "YES" << el #define NO cout << "NO" << el #define inp(x) for(auto &i:x)cin>>i #define eps (1e-10) #define Equals(a,b) (fabs((a) - (b)) < eps ) #define debug(x) cerr << #x << " = " << x << el using ll = long long; using ull = unsigned long long; using i128 = __int128_t; using pii = pair; using pll = pair; using vi = vector; using vl = vector; using vvl = vector>; using vs = vector; using vb = vector; const double pi = 3.141592653589793238; const int inf = 1073741823; const ll infl = 1LL << 60; const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; const string abc = "abcdefghijklmnopqrstuvwxyz"; const ll MOD = 998244353; #include using namespace atcoder; using mint = modint998244353; using vm = vector; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n,pre=-1; cin>>n; fenwick_tree fw(n+1); REP(i,1,n)fw.add(i,1); vi ans; auto ask=[&](char c,int x){ if(c=='?'){ cout<>x; if(x==-1)return 0; if(pre!=-1){ int y=pre-x+1; int l=0,r=n+1; while(r-l>1){ int m=(l+r)/2; int z=fw.sum(0,m); if(z>=y)r=m; else l=m; } ans.push_back(l); fw.add(l,-1); } pre=x; if(x==0){ rep(j,1,n+1){ if(fw.sum(j,j+1)==1)ans.push_back(j); } ask('!',0); return 0; } if(x==(n-i)*(n-i+1)/2){ for(int j=n;j>0;j--){ if(fw.sum(j,j+1)==1)ans.push_back(j); } ask('!',0); return 0; } } }