#include <bits/stdc++.h>
using namespace std;
const int maxn = 400100;
int c[maxn];
int a[maxn];
int n, m;
int f[maxn];
int b[maxn];
int ask(int x) {
  int res = 0;
  for (; x; x -= x & -x) res = max(res, c[x]);
  return res;
}
void update(int x, int v) {
  for (; x <= m; x += x & -x) c[x] = max(c[x], v);
}
int main() {
  scanf("%d", &n);
  vector<int> q;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", a + i);
    a[i] -= i;
    q.push_back(a[i]);
    q.push_back(a[i] - 1);
  }
  sort(q.begin(), q.end());
  q.erase(unique(q.begin(), q.end()), q.end());
  m = q.size();
  for (int i = 1; i <= n; ++i) {
    a[i] = lower_bound(q.begin(), q.end(), a[i]) - q.begin() + 1;
    f[i] = ask(a[i]) + 1;
    update(a[i], f[i]);
    if (f[i - 1] > f[i] || f[i - 1] == f[i] && a[i] > b[i - 1])
      f[i] = f[i - 1], b[i] = b[i - 1];
    else
      b[i] = a[i];
  }
  memset(c, 0, sizeof(c));
  int ans = min(f[n], n - 1);
  for (int i = n; i >= 2; --i) {
    int tmp = ask(m - a[i] + 1) + 1;
    update(m - a[i] + 1, tmp);
    if (i > 2)
      ans = max(ans, f[i - 2] + ask(m - (b[i - 2] - 1) + 1));
    else
      ans = max(ans, tmp);
  }
  ans = n - 1 - ans;
  printf("%d\n", ans);
  return 0;
}
