#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
const int N2 = N << 1;
struct Map {
  int ord[N2];
  int m;
  void init(int a[], int n) {
    for (int i = 0; i < n; ++i) ord[i] = a[i];
    for (int i = 0; i < n; ++i) ord[i + n] = a[i] - 1;
    sort(ord, ord + 2 * n);
    m = unique(ord, ord + 2 * n) - ord;
  }
  int one(int val) { return lower_bound(ord, ord + m, val) - ord; }
} mp;
struct SegTree {
  int mx[N2 << 2];
  void init(int l, int r, int rt) {
    if (l == r)
      mx[rt] = 0;
    else {
      int m = (l + r) >> 1;
      init(l, m, rt << 1);
      init(m + 1, r, rt << 1 | 1);
    }
  }
  void update(int pos, int val, int l, int r, int rt) {
    if (l == r) {
      mx[rt] = max(val, mx[rt]);
      return;
    }
    int m = (l + r) >> 1;
    if (pos <= m)
      update(pos, val, l, m, rt << 1);
    else
      update(pos, val, m + 1, r, rt << 1 | 1);
    mx[rt] = max(mx[rt << 1], mx[rt << 1 | 1]);
  }
  int query(int L, int R, int l, int r, int rt) {
    if (L <= l && r <= R) {
      return mx[rt];
    }
    int m = (l + r) >> 1, res = 0;
    if (L <= m) res = max(res, query(L, R, l, m, rt << 1));
    if (R > m) res = max(res, query(L, R, m + 1, r, rt << 1 | 1));
    return res;
  }
} sgtree;
int a[N];
int dp[N];
int inc[N];
map<int, int> mm;
int solve(int n) {
  int m = 0;
  for (int i = 0; i < n; ++i) {
    if (i == 0) {
      dp[i] = 1;
      inc[m++] = a[i];
    } else {
      int j = upper_bound(inc, inc + m, a[i]) - inc;
      dp[i] = j + 1;
      inc[j] = a[i];
      if (j == m) m++;
    }
  }
  int res = m;
  m = 0;
  for (int i = n - 1; i >= 0; --i) {
    if (i == n - 1) {
      dp[i] = 1;
      inc[m++] = -a[i];
    } else {
      int j = upper_bound(inc, inc + m, -a[i]) - inc;
      dp[i] = j + 1;
      inc[j] = -a[i];
      if (j == m) m++;
    }
    mm[a[i]] = max(mm[a[i]], dp[i]);
    if (i - 2 >= 0) {
      res = max(res, dp[i - 2] + mm[a[i - 2] - 1]);
    }
  }
  return res;
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    a[i] -= i;
  }
  int res = max(n - solve(n) - 1, 0);
  cout << res << endl;
  return 0;
}
