#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 200000;
int n;
int a[MAXN];
int b[MAXN], nb;
int bit[MAXN + 1];
int bget(int idx) {
  ++idx;
  int ret = 0;
  while (idx > 0) {
    ret = max(ret, bit[idx]);
    idx -= idx & -idx;
  }
  return ret;
}
void bmod(int idx, int val) {
  ++idx;
  while (idx <= nb) {
    bit[idx] = max(bit[idx], val);
    idx += idx & -idx;
  }
}
int l[MAXN], r[MAXN];
void run() {
  scanf("%d", &n);
  for (int i = (0); i < (n); ++i) scanf("%d", &a[i]);
  for (int i = (0); i < (n); ++i) a[i] -= i;
  nb = 0;
  for (int i = (0); i < (n); ++i) b[nb++] = a[i];
  sort(b, b + nb);
  nb = unique(b, b + nb) - b;
  for (int i = (0); i < (n); ++i) a[i] = lower_bound(b, b + nb, a[i]) - b;
  memset(bit, 0, sizeof(bit));
  for (int i = (0); i < (n); ++i) {
    int pos = a[i];
    l[i] = bget(pos) + 1;
    bmod(pos, l[i]);
  }
  memset(bit, 0, sizeof(bit));
  int ans = INT_MAX;
  for (int i = n - 1; i >= 0; --i) {
    if (i - 1 >= 0) {
      int pos = a[i - 1] == 0 || b[a[i - 1] - 1] < b[a[i - 1]] - 1
                    ? a[i - 1]
                    : a[i - 1] - 1;
      pos = nb - pos - 1;
      int keep = l[i - 1] + bget(pos);
      ans = min(ans, n - 1 - keep);
    }
    {
      int keep = bget(nb - 1);
      ans = min(ans, n - 1 - keep);
    }
    {
      int pos = nb - a[i] - 1;
      r[i] = bget(pos) + 1;
      bmod(pos, r[i]);
    }
  }
  printf("%d\n", ans);
}
int main() {
  run();
  return 0;
}
