#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int N = 4e5 + 5;
int F[N], A[N], B[N], dp[N], m, n, i, j, t, asd;
void up(int x, int t) {
  for (; x <= m; x += x & -x) F[x] = max(F[x], t);
}
int qry(int x) {
  int t = 0;
  for (; x; x -= x & -x) t = max(F[x], t);
  return t;
}
int main() {
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> A[i];
    B[++m] = A[i] - i;
    B[++m] = A[i] - i + 1;
  }
  sort(B + 1, B + m + 1);
  for (i = n; i; i--) {
    j = lower_bound(B + 1, B + m + 1, A[i] - i) - B;
    dp[i] = t = qry(m - j + 1) + 1;
    up(m - j + 1, t);
  }
  memset(F, 0, sizeof F);
  for (i = 2; i <= n; i++) {
    j = lower_bound(B + 1, B + m + 1, A[i] - i + 1) - B;
    asd = max(asd, dp[i] + qry(j));
    j = lower_bound(B + 1, B + m + 1, A[i - 1] - (i - 1)) - B;
    t = qry(j) + 1;
    up(j, t);
  }
  asd = max(asd, qry(m));
  cout << n - asd - 1;
  return 0;
}
