func_code_string: #include <bits/stdc++.h>   using namespace std;   template <typename T>   vector<T> uniq(vector<T> v) {     sort(v.begin(), v.end());     v.erase(unique(v.begin(), v.end()), v.end());     return v;   }   template <typename T>   struct RMQ {     using F = function<T(const T &, const T &)>;     int n;     vector<T> t;     F f;     RMQ(int n, F f, T df = 0) : n(n), f(f), t(vector<T>(n << 1, df)) {}     void modify(int p, T v) {       for (t[p += n] = v; p > 1; p >>= 1) t[p >> 1] = f(t[p], t[p ^ 1]);     }     T query(int l, int r, T res = 0) {       for (l += n, r += n + 1; l < r; l >>= 1, r >>= 1) {         if (l & 1) res = f(res, t[l++]);         if (r & 1) res = f(res, t[--r]);       }       return res;     }   };   int32_t main() {     ios_base ::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     vector<int> l(n + 1, 0), r(n + 1, 0);     vector<int> a(n);     for (int &x : a) cin >> x;     vector<int> b;     for (int i = 0; i < n; i++) {       b.push_back(a[i] - i);       b.push_back(a[i] - i + 1);     }     b = uniq(b);     int ptr = 0;     map<int, int> mp;     for (int x : b) mp[x] = ++ptr;     RMQ<int> ST(b.size() + 10, [&](int p, int q) { return max(p, q); });     for (int i = 0; i < n; i++) {       l[i] = 1 + ST.query(1, mp[a[i] - i]);       ST.modify(mp[a[i] - i], l[i]);     }     ST = RMQ<int>(b.size() + 10, [&](int p, int q) { return max(p, q); });     for (int i = n - 1; i >= 0; i--) {       r[i] = 1 + ST.query(mp[a[i] - i], b.size() + 9);       if (i + 1 < n) {         int x = 1 + ST.query(mp[a[i + 1] - (i + 1) + 1], b.size() + 9);         ST.modify(mp[a[i + 1] - (i + 1) + 1], x);       }     }     int ans = 0;     for (int i = 0; i < n; i++) ans = max(ans, l[i] + r[i] - 1);     cout << n - 1 - min(n - 1, ans) << endl;   }   