#include <bits/stdc++.h>
using namespace std;
const double pi = 3.1415926535897932384626433832795;
const double eps = 1e-12;
const int INF = 1 << 30;
const long long LINF = 1LL << 62;
const int BUFFER_SZ = 1 << 10;
const int MOD = 1000 * 1000 * 1000 + 7;
char BUFFER[BUFFER_SZ];
int gi() {
  int x;
  scanf("%d", &x);
  return x;
}
long long gll() {
  long long x;
  scanf("%lld", &x);
  return x;
}
vector<int> gvi(int n) {
  vector<int> a;
  while (n-- > 0) a.push_back(gi());
  return a;
}
string gs() {
  scanf("%s", BUFFER);
  return string(BUFFER);
}
template <class T>
void print(vector<T> &x, string format) {
  format += "%c";
  for (int i = 0; i < x.size(); ++i)
    printf(format.c_str(), x[i], i + 1 == x.size() ? '\n' : ' ');
}
int R0[222222];
int R1[222222];
int solve(vector<int> &a) {
  int n = a.size();
  for (int i = 0; i < n + 1; ++i) R0[i] = R1[i] = INF;
  R0[0] = -INF;
  int toAdd = 0;
  int r0 = 1;
  int r1 = 0;
  for (int i = 0; i < a.size(); ++i) {
    int v1 = upper_bound(R1, R1 + r1 + 1, a[i] - i + 1) - R1;
    if (v1 > r1) ++r1;
    R1[v1] = a[i] - i + 1;
    R1[toAdd] = min(R0[toAdd], R1[toAdd]);
    if (toAdd > r1) ++r1;
    int v0 = upper_bound(R0, R0 + r0 + 1, a[i] - i) - R0;
    if (v0 >= r0) ++r0;
    R0[v0] = a[i] - i;
    toAdd = v0;
  }
  return max(0, (int)a.size() - min(n, r1 + 1));
}
int main() {
  int n = gi();
  vector<int> a = gvi(n);
  printf("%d\n", solve(a));
  return 0;
}
