#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    int64_t seed = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count();
    mt19937_64 rnd(seed);
    int n;
    cin>>n;
    uniform_int_distribution<int> mm(1,n);
    deque<int> que;
    int l = 1;
    int r = 2;
    cout<<"? 1 2";
    int t;
    cin>>t;
    if(t==1);
    else swap(l,r);
    que.push_back(l);
    que.push_back(r);
    int ni = 3;
    vector<int> vis(n+1,0);
    vis[1] = 1;
    vis[2] = 1;
    for(;ni<=n;ni++){
        int t1,t2;
        cout<<"? "<<que.front()<<" "<<ni<<endl;
        cin>>t1;
        cout<<"? "<<que.back()<<" "<<ni<<endl;
        cin>>t2;
        if(t2==1){
            que.push_back(ni);
            continue;
        }
        if(t1==0){
            que.push_front(ni);
            continue;
        }
        int l = 0;
        int r = que.size() - 1;
        while(r-l>1){
            int mid = (r+l)/2;
            cout<<"? "<<que[mid]<<" "<<ni<<endl;
            int op;
            cin>>op;
            if(op==1) l = mid;
            else r = mid;
        }
        deque<int> nxt;
        for(int i = 0;i<=l;i++) nxt.push_back(que[i]);
        nxt.push_back(ni);
        for(int i = r;i<que.size();i++) nxt.push_back(que[i]);
        swap(nxt,que);
    }
    cout<<"!"<<endl;
    cout<<n-1<<endl;
    for(int i = 0;i<n;i++){
        if(i!=0) cout<<" ";
        cout<<que[i];
    }
    cout<<endl;
}