#include <bits/stdc++.h>
using namespace std;
const int MAX = 4e5 + 10;
int arr[MAX];
int n;
int bit[2][MAX];
int dp[MAX][2];
void update(bool t, int i, int x) {
  for (; i <= n * 2; i += (i & (-i))) bit[t][i] = max(bit[t][i], x);
}
int query(bool t, int i) {
  int ans = 0;
  for (; i > 0; i -= (i & (-i))) ans = max(ans, bit[t][i]);
  return ans;
}
void compress() {
  vector<int> v;
  for (int i = 1; i <= n; ++i) v.push_back(arr[i]), v.push_back(arr[i] + 1);
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  for (int i = 1; i <= n; ++i)
    arr[i] = lower_bound(v.begin(), v.end(), arr[i]) - v.begin() + 1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> arr[i];
    arr[i] -= i;
  }
  compress();
  for (int i = 1; i <= n; ++i)
    dp[i][0] = query(0, arr[i]) + 1, update(0, arr[i], dp[i][0]);
  memset(bit, 0, sizeof(bit));
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    dp[i][1] = max(query(0, arr[i] + 1), query(1, arr[i] + 1)) + 1;
    ans = max(ans, dp[i][1]);
    update(1, arr[i] + 1, dp[i][1]);
    if (i > 1) update(0, arr[i - 1], dp[i - 1][0]);
  }
  return cout << max(0, n - 1 - ans) << "\n", 0;
}
