#include <bits/stdc++.h>
using namespace std;
int a[250200], pos[250200], b[250200][2], c[250200], d[250200], n, ans, l, r,
    mid;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) a[i] += (n - i);
  c[0] = 0;
  for (int i = 1; i <= n; i++) c[i] = d[i] = 1001500007;
  for (int i = 1; i <= n; i++) {
    l = 0;
    r = n;
    while (r - l > 1) {
      mid = (l + r) >> 1;
      if (a[i] < d[mid])
        r = mid;
      else
        l = mid;
    }
    if (d[l + 1] >= a[i]) {
      d[++l] = a[i];
      while (c[l] == a[i] && pos[l] < i - 1) d[++l] = a[i];
    }
    a[i]--;
    l = 0;
    r = n;
    while (r - l > 1) {
      mid = (l + r) >> 1;
      if (a[i] < c[mid])
        r = mid;
      else
        l = mid;
    }
    if (c[l + 1] > a[i]) {
      c[l + 1] = a[i];
      pos[l + 1] = i;
    }
  }
  for (int i = 0; i <= n; i++)
    if (c[i] < 1001500007 || d[i] < 1001500007) ans = i;
  cout << max(0, n - ans - 1) << endl;
}
