#include <bits/stdc++.h>
using namespace std;
int n;
int a[200010], mxl[200010], mxr[200010];
int findup() {
  vector<int> res;
  for (int i = 1; i <= n; i++) {
    auto it = upper_bound(res.begin(), res.end(), a[i]);
    if (it == res.end()) {
      res.push_back(a[i]);
    } else {
      *it = a[i];
    }
    it = upper_bound(res.begin(), res.end(), a[i]);
    mxl[i] = it - res.begin();
  }
  return res.size();
}
void finddown() {
  vector<int> res;
  for (int i = n; i >= 1; i--) {
    a[i] *= -1;
    ;
    auto it = upper_bound(res.begin(), res.end(), a[i]);
    if (it == res.end()) {
      res.push_back(a[i]);
    } else {
      *it = a[i];
    }
    it = upper_bound(res.begin(), res.end(), a[i]);
    mxr[i] = (it - res.begin());
    ;
    a[i] *= -1;
  }
}
map<int, int> m;
vector<int> v;
int mx;
void tmd() {
  sort(v.begin(), v.end());
  m[v[0]] = 1;
  mx = 1;
  for (int i = 1; i < (int)(v).size(); i++) {
    if (v[i] != v[i - 1]) m[v[i]] = ++mx;
  }
}
stack<int> s[400010];
int T[400010 * 4];
void del(int l, int r, int rt, int x) {
  if (l == r) {
    s[l].pop();
    T[rt] = s[l].top();
    return;
  }
  if ((l + r) / 2 >= x)
    del(l, (l + r) / 2, rt << 1, x);
  else
    del((l + r) / 2 + 1, r, rt << 1 | 1, x);
  T[rt] = max(T[rt << 1], T[rt << 1 | 1]);
}
void add(int l, int r, int rt, int x, int val) {
  if (l == r) {
    T[rt] = val;
    s[l].push(val);
    return;
  }
  if ((l + r) / 2 >= x)
    add(l, (l + r) / 2, rt << 1, x, val);
  else
    add((l + r) / 2 + 1, r, rt << 1 | 1, x, val);
  T[rt] = max(T[rt << 1], T[rt << 1 | 1]);
}
int query(int l, int r, int rt, int L, int R) {
  if (l >= L && r <= R) return T[rt];
  int ret = query((l + r) / 2 + 1, r, rt << 1 | 1, L, R);
  if ((l + r) / 2 >= L) ret = max(ret, query(l, (l + r) / 2, rt << 1, L, R));
  return ret;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    a[i] -= i;
    v.push_back(a[i]);
    v.push_back(a[i] - 1);
  }
  tmd();
  finddown();
  int res = findup();
  if (res == n) {
    cout << 0;
    return 0;
  }
  for (int i = 1; i <= mx; i++) s[i].push(0);
  for (int i = n; i >= 2; i--) {
    add(1, mx, 1, m[a[i]], mxr[i]);
  }
  for (int i = 2; i <= n; i++) {
    del(1, mx, 1, m[a[i]]);
    res = max(res, mxl[i - 1] + query(1, mx, 1, m[a[i - 1] - 1], mx));
  }
  cout << n - res - 1;
  return 0;
}
