#include <bits/stdc++.h>
using namespace std;
const int kn = 2e5 + 1;
int n, a[kn], dp[2][kn];
int tree[2][2 * kn], ans = 0, cur = 0;
vector<pair<int, int> > V;
void upd(int num, int id, int val) {
  while (id <= 4e5) {
    tree[num][id] = max(tree[num][id], val);
    id += (id & -id);
  }
}
int get(int num, int id) {
  int ans = -1;
  while (id) {
    ans = max(ans, tree[num][id]);
    id -= (id & -id);
  }
  return ans;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    a[i] -= i;
    V.push_back({a[i], i});
    V.push_back({a[i] + 1, 0});
  }
  sort(V.begin(), V.end());
  for (int i = 0; i < V.size(); i++) {
    if (i == 0 || V[i].first > V[i - 1].first) cur++;
    if (V[i].second) a[V[i].second] = cur;
  }
  for (int i = 1; i <= 4e5; i++) tree[1][i] = -1;
  for (int i = 1; i <= n; i++) {
    dp[0][i] = get(0, a[i]) + 1;
    dp[1][i + 1] = get(0, a[i + 1] + 1) + 1;
    dp[1][i] = max(dp[1][i], get(1, a[i]) + 1);
    upd(1, a[i], dp[1][i]);
    upd(0, a[i], dp[0][i]);
    ans = max(ans, max(dp[0][i] + 1, dp[1][i] + 1));
  }
  printf("%d\n", max(0, n - ans));
}
