#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 4;
int Fr[N], Rv[N];
set<pair<int, int> > Set;
int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    a[i] += (n - i);
    Set.insert(make_pair(a[i], i));
  }
  int LIS = 0;
  vector<int> d;
  for (int i = 0; i < n; i++) {
    int x = a[i];
    vector<int>::iterator it = upper_bound(d.begin(), d.end(), x);
    if (it == d.end())
      d.push_back(x);
    else
      *it = x;
    Fr[i] = upper_bound(d.begin(), d.end(), x) - d.begin();
    LIS = max(LIS, Fr[i]);
  }
  d.clear();
  vector<int> b = a;
  reverse(b.begin(), b.end());
  for (int i = 0; i < n; i++) b[i] = -b[i];
  for (int i = 0; i < n; i++) {
    int x = b[i];
    vector<int>::iterator it = upper_bound(d.begin(), d.end(), x);
    if (it == d.end())
      d.push_back(x);
    else
      *it = x;
    Rv[n - i - 1] = upper_bound(d.begin(), d.end(), x) - d.begin();
  }
  if (LIS >= n - 1) {
    printf("0");
    return 0;
  }
  int ans = LIS;
  Set.erase(make_pair(a[0], 0));
  for (int i = 0; i < n; i++) {
    int cur1 = Fr[i], cur2;
    if (i != n - 1) Set.erase(make_pair(a[i + 1], i + 1));
    auto it = Set.lower_bound(make_pair(a[i] - 1, 0));
    if (it != Set.end()) {
      cur2 = Rv[(*it).second];
    } else {
      cur2 = 0;
    }
    ans = max(ans, cur1 + cur2);
  }
  ans = n - 1 - ans;
  cout << ans << endl;
  return 0;
}
