#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int a[N], b[N], c[N << 1], d[N], e[N << 1];
int s1[N], s2[N];
int cnt, tot;
int n, mx, ans = 0;
inline void up(int &a, int b) {
  if (a < b) a = b;
}
void update(int x, int val) {
  for (; x <= mx; x += x & -x) up(c[x], val);
}
int query(int x) {
  int ret = 0;
  for (; x; x -= x & -x) up(ret, c[x]);
  return ret;
}
int main() {
  scanf("%d", &n);
  for (int i(1); i <= (n); ++i) scanf("%d", a + i);
  for (int i(1); i <= (n); ++i) b[i] = a[i] - i, d[i] = a[i] - i + 1;
  for (int i(1); i <= (n); ++i) e[++tot] = b[i], e[++tot] = d[i];
  sort(e + 1, e + n * 2 + 1);
  cnt = unique(e + 1, e + tot + 1) - e - 1;
  for (int i(1); i <= (n); ++i)
    b[i] = lower_bound(e + 1, e + cnt + 1, b[i]) - e;
  for (int i(1); i <= (n); ++i)
    d[i] = lower_bound(e + 1, e + cnt + 1, d[i]) - e;
  memset(c, 0, sizeof c);
  mx = 4e5;
  for (int i(1); i <= (n); ++i) {
    s1[i] = query(b[i]) + 1;
    update(b[i], s1[i]);
  }
  memset(c, 0, sizeof c);
  for (int i(1); i <= (n); ++i) d[i] = mx - d[i] + 1;
  for (int i(n); i >= (1); --i) {
    s2[i] = query(d[i]) + 1;
    update(d[i], s2[i]);
  }
  for (int i(1); i <= (n); ++i) d[i] = mx - d[i] + 1;
  memset(c, 0, sizeof c);
  ans = s1[n - 1];
  up(ans, s2[2]);
  for (int i(2); i <= (n); ++i) {
    up(ans, query(d[i]) + s2[i]);
    update(b[i - 1], s1[i - 1]);
  }
  memset(c, 0, sizeof c);
  for (int i(1); i <= (n); ++i) b[i] = mx - b[i] + 1, d[i] = mx - d[i] + 1;
  for (int i(n - 1); i >= (1); --i) {
    up(ans, query(b[i]) + s1[i]);
    update(d[i + 1], s2[i + 1]);
  }
  printf("%d\n", n - ans - 1);
  return 0;
}
