func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long INF = 1e9 + 5, NMAX = 2e5 + 5, MOD = 998244353, N = 1e9 + 5,                   LOG = 25;   const long double EPS = 1e-8, pi = 3.14159265358979323846;   vector<long long> res;   bool first(long long k, vector<long long> &v) {     long long index = k;     res.clear();     vector<long long> ost;     for (long long i = 0; i < k && index < v.size(); ++i, ++index) {       while (index < v.size() && v[index] <= v[i]) ost.push_back(v[index++]);       if (index == v.size()) return false;       res.push_back(v[index]);       res.push_back(v[i]);     }     while (index < v.size() && v[index] <= res.back()) ost.push_back(v[index++]);     if (index == v.size()) return false;     while (index < v.size()) res.push_back(v[index++]);     for (long long o : ost) res.push_back(o);     return true;   }   signed solve() {     long long n;     cin >> n;     vector<long long> v(n);     for (long long i = 0; i < n; ++i) cin >> v[i];     if (n < 3) {       cout <<  0 n ;       for (long long x : v) cout << x <<    ;       return 0;     }     sort(v.begin(), v.end());     long long l = 0, r = n - 2;     while (l + 1 < r) {       long long m = (l + r) / 2;       if (first(m, v)) {         l = m;       } else {         r = m - 1;       }     }     if (first(r, v)) {       cout << r <<   n ;       for (long long x : res) cout << x <<    ;     } else {       first(l, v);       cout << l <<   n ;       for (long long x : res) cout << x <<    ;     }   }   signed main() {     {       ios_base::sync_with_stdio(0);       cin.tie(0);       cout.tie(0);     }     long long t = 1;     while (t-- > 0) {       solve();     }   }   