#include int main() { using namespace std; unsigned long N; cin >> N; vector A(N); iota(begin(A), end(A), 1); mt19937_64 mt{random_device{}()}; const auto cmp{[](unsigned long x){ return [x](unsigned long y) -> bool { if(x == y)return 0; cout << "? " << y << " " << x << endl; unsigned long t; cin >> t; return t; }; }}; [rec_impl{[&A, &mt, &cmp](auto&& f, unsigned long l, unsigned long r) -> void { while(l + 1 < r){ unsigned long d{uniform_int_distribution{l, r - 1}(mt)}; const auto m{partition(begin(A) + l, begin(A) + r, cmp(A[d])) - begin(A)}; f(f, l, m); l = m + 1; } }}, &N]{rec_impl(rec_impl, 0, N);}(); cout << "!" << endl; cout << N - 1 << endl; for(const auto a : A)cout << a << " "; cout << endl; return 0; }