#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int INF = 2000000000;
const long long BIG = 1446803456761533460LL;
const int maxn = 200010;
int n, A[maxn], val[maxn], lis[maxn], ris[maxn];
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  A[0] = -INF;
  for (int i = 1; i < n + 1; ++i) cin >> A[i], A[i] -= i;
  memset(lis, 127, sizeof lis);
  memset(ris, 127, sizeof ris);
  int ans = 0;
  for (int i = 1; i < n + 1; ++i) {
    int id = upper_bound(lis, lis + n + 1, A[i]) - lis;
    lis[id] = A[i];
    val[i] = id + 1;
    ans = max(ans, (val[i]));
  }
  for (int i = (n + 1) - 1; i >= 1; --i) {
    int v = upper_bound(ris, ris + n + 1, -(A[i - 1])) - ris;
    ans = max(ans, (val[i - 1] + (v + 1)));
    int id = upper_bound(ris, ris + n + 1, -(A[i] + 1)) - ris;
    ris[id] = -(A[i] + 1);
  }
  cout << n - ans << '\n';
}
