#include <bits/stdc++.h>
using namespace std;
long long read() {
  long long a = 0, b = getchar(), c = 1;
  while (!isdigit(b)) c = b == '-' ? -1 : 1, b = getchar();
  while (isdigit(b)) a = a * 10 + b - '0', b = getchar();
  return a * c;
}
int n, m, d[2][200005], a[200005];
void gao(int x) {
  int res = 0, ab = 1e9;
  for (int i = 0; i < n; i++) {
    int y = d[0][i], z = d[1][i];
    if (y == z) continue;
    ab = min(ab, y);
    ab = min(ab, z);
    if (y > x and z > x)
      res += y;
    else
      res += ab;
  }
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) a[i] = read() - i;
  memset(d, 0x3f, sizeof(d));
  for (int i = 1; i <= n; i++) {
    int x = upper_bound(d[0] + 1, d[0] + i + 1, a[i]) - d[0];
    int y = upper_bound(d[1] + 1, d[1] + 1 + i, a[i] + 1) - d[1];
    d[1][m] = min(d[0][m], d[1][m]);
    d[1][y] = a[i] + 1, d[0][m = x] = a[i];
  }
  gao(1);
  int x = lower_bound(d[0] + 1, d[0] + n + 1, 1e9) - d[0] - 1;
  int y = lower_bound(d[1] + 1, d[1] + n + 1, 1e9) - d[1] - 1;
  printf("%d\n", max(0, min(n - x, n - 1 - y)));
  return 0;
}
