#include using namespace std; int main() { int N; cin >> N; vectorans; ans.push_back(1); for(int i = 2; i <= N; i++) { cout << "? " << ans.back() << " " << i << endl; int f; cin >> f; if(f) { ans.push_back(i); continue; } if(i == 2) { ans = {2,1}; continue; } cout << "? " << i << " " << ans[0] << endl; cin >> f; if(f) { vectornxt; nxt.push_back(i); for(int j:ans) nxt.push_back(j); ans = nxt; continue; } if(i == 3) { ans = {ans[0],i,ans[1]}; continue; } int l = 0,r = i-2; while(l+1 < r) { int mid = (l+r)/2; cout << "? " << ans[mid] << " " << i << endl; cin >> f; if(f) { l = mid; } else { r = mid; } } vectornxt; for(int j = 0; j < ans.size(); j++) { if(j <= l) { nxt.push_back(ans[j]); } if(j == l) { nxt.push_back(i); } if(l < j) { nxt.push_back(ans[j]); } } ans = nxt; } cout << "!" << endl; cout << N-1 << endl; for(int i = 0; i <= N; i++) { cout << ans[i] << ((i == N)?"\n":" "); } }