#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
int k, n, m, x, Ans, pos;
int f[2][N];
int main() {
  scanf("%d", &n);
  memset(f, 63, sizeof(f));
  f[0][0] = -1e9;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    int t = upper_bound(f[1] + 1, f[1] + n + 1, x - i + 1) - f[1];
    f[1][t] = x - i + 1;
    Ans = max(Ans, t);
    f[1][pos] = min(f[1][pos], f[0][pos]);
    Ans = max(Ans, pos);
    t = upper_bound(f[0] + 1, f[0] + n + 1, x - i) - f[0];
    f[0][pos = t] = x - i;
  }
  printf("%d\n", max(0, n - Ans - 1));
  return 0;
}
