#include <bits/stdc++.h>
using namespace std;
int const N = 200000;
int pr[N], x[N], fn[N << 1 | 1];
vector<int> mp;
inline void ad(int i, int x) {
  i = (int)mp.size() - i;
  while (i <= (int)mp.size()) fn[i] = max(fn[i], x), i += i & -i;
}
inline int gt(int i) {
  i = (int)mp.size() - i;
  int an = 0;
  while (i) an = max(an, fn[i]), i ^= i & -i;
  return an;
}
int main() {
  int n;
  scanf("%d", &n);
  mp.resize(n << 1);
  for (int i = 0; i < (int)(n); ++i)
    scanf("%d", x + i), x[i] -= i, mp[i << 1] = x[i], mp[i << 1 | 1] = x[i] - 1;
  sort(mp.begin(), mp.end());
  mp.resize(unique(mp.begin(), mp.end()) - mp.begin());
  for (int i = 0; i < (int)(n); ++i)
    x[i] = lower_bound(mp.begin(), mp.end(), x[i]) - mp.begin();
  int an = 1e9;
  vector<int> v;
  for (int i = 0; i < (int)(n); ++i) {
    if (i + 1 == n) an = n - 1 - (int)v.size();
    vector<int>::iterator it = upper_bound(v.begin(), v.end(), x[i]);
    pr[i] = it - v.begin() + 1;
    if (it == v.end())
      v.push_back(x[i]);
    else
      *it = x[i];
  }
  an = min(an, n - (int)v.size());
  v.clear();
  for (int i = n - 1; i >= 1; --i) {
    vector<int>::iterator it = upper_bound(v.begin(), v.end(), -x[i]);
    ad(x[i], it - v.begin() + 1);
    an = min(
        an, n - 1 - (gt(i == 1 ? 0 : x[i - 2] - 1) + (i == 1 ? 0 : pr[i - 2])));
    if (it == v.end())
      v.push_back(-x[i]);
    else
      *it = -x[i];
  }
  printf("%d\n", an);
}
