#include <bits/stdc++.h>
using namespace std;
const int MN = 200010;
int N;
int A[MN], invo[MN];
vector<pair<int, int> > ord;
struct BIT {
  vector<int> tree;
  void init() { tree = vector<int>(4 * N, 0); }
  void upd(int idx, int val, int l, int r, int n) {
    if (idx < l || r < idx) return;
    if (l == r) {
      tree[n] = val;
      return;
    }
    int m = (l + r) >> 1;
    upd(idx, val, l, m, 2 * n);
    upd(idx, val, m + 1, r, 2 * n + 1);
    tree[n] = max(tree[2 * n], tree[2 * n + 1]);
  }
  int quer(int a, int b, int l, int r, int n) {
    if (b < l || r < a) return 0;
    if (a <= l && r <= b) return tree[n];
    int m = (l + r) >> 1;
    int L = quer(a, b, l, m, 2 * n);
    int R = quer(a, b, m + 1, r, 2 * n + 1);
    return max(L, R);
  }
} bit1, bit2;
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &A[i]);
    ord.push_back({A[i] - i, i});
  }
  sort(ord.begin(), ord.end());
  for (int i = 0; i < N; i++) invo[ord[i].second] = i;
  int ans = 0;
  bit2.init();
  for (int i = N - 1; i >= 0; i--) {
    int t = 1 + bit2.quer(invo[i] + 1, N - 1, 0, N - 1, 1);
    bit2.upd(invo[i], t, 0, N - 1, 1);
    ans = max(ans, t);
    if (i) ans = max(ans, t + 1);
  }
  int t = 0, p = -1;
  bit1.init();
  for (int i = 0; i < N; i++) {
    bit2.upd(invo[i], 0, 0, N - 1, 1);
    if (p != -1) {
      int s = 0, e = N - 1, q = N;
      while (s <= e) {
        int m = (s + e) >> 1;
        if (ord[m].first + 1 >= ord[p].first) {
          q = m;
          e = m - 1;
        } else
          s = m + 1;
      }
      ans = max(ans, 1 + t + bit2.quer(q, N - 1, 0, N - 1, 1));
    }
    t = 1 + bit1.quer(0, invo[i] - 1, 0, N - 1, 1);
    p = invo[i];
    bit1.upd(p, t, 0, N - 1, 1);
  }
  printf("%d", N - ans);
}
