#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
int ans = 1 << 30, res, n, tp, cnt;
int c1[N * 3], c2[N * 3], v[N * 50], g[N * 50], a[N];
inline int gi() {
  int x = 0, o = 1;
  char ch = getchar();
  while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
  if (ch == '-') o = -1, ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x * o;
}
inline void ins(int x, int f) {
  while (x <= cnt) {
    if (f > c1[x]) v[++tp] = x, g[tp] = c1[x], c1[x] = f;
    x += (x & -x);
  }
}
inline int get(int x) {
  int ret = 0;
  while (x) ret = max(ret, c1[x]), x -= (x & -x);
  return ret;
}
inline void add(int x, int f) {
  while (x) {
    if (f > c2[x]) v[++tp] = x, g[tp] = c2[x], c2[x] = f;
    x -= (x & -x);
  }
}
inline int query(int x) {
  int ret = 0;
  while (x <= cnt) ret = max(ret, c2[x]), x += (x & -x);
  return ret;
}
inline void solve(int l, int r, int res) {
  if (l == r) {
    ans = min(ans, res);
    return;
  }
  int mid = (l + r) >> 1, la = tp, now = res;
  for (int i = r; i > mid; i--) {
    int t = query(a[i]) + 1;
    add(a[i], t), now = min(now, n - get(a[i] + 1) - t - 1);
  }
  solve(l, mid, now);
  while (tp > la) c2[v[tp]] = g[tp], --tp;
  for (int i = l; i <= mid; i++) {
    int t = get(a[i]) + 1;
    ins(a[i], t), res = min(res, n - query(a[i] - 1) - t - 1);
  }
  solve(mid + 1, r, res);
  while (tp > la) c1[v[tp]] = g[tp], --tp;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    a[i] = gi() - i;
    v[++cnt] = a[i] - 1, v[++cnt] = a[i], v[++cnt] = a[i] + 1;
  }
  sort(v + 1, v + 1 + cnt);
  cnt = unique(v + 1, v + 1 + cnt) - v - 1;
  for (int i = 1; i <= n; i++) a[i] = lower_bound(v + 1, v + 1 + cnt, a[i]) - v;
  solve(1, n, n);
  cout << ans;
  return 0;
}
