#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int A[N], pre[N], suf[N];
int tree[N << 2];
map<int, int> M;
map<int, int> revM;
void build(int node, int l, int r) {
  tree[node] = 0;
  if (l == r) return;
  int mid = (l + r) >> 1;
  int left = node << 1;
  int right = left + 1;
  build(left, l, mid);
  build(right, mid + 1, r);
  return;
}
int query(int node, int l, int r, int a, int b) {
  if (l == a && r == b) return tree[node];
  int mid = (l + r) >> 1;
  int left = node << 1;
  int right = left + 1;
  if (b <= mid)
    return query(left, l, mid, a, b);
  else if (a > mid)
    return query(right, mid + 1, r, a, b);
  return max(query(left, l, mid, a, mid), query(right, mid + 1, r, mid + 1, b));
}
void update(int node, int l, int r, int ind, int val) {
  if (l == r) {
    tree[node] = val;
    return;
  }
  int mid = (l + r) >> 1;
  int left = node << 1;
  int right = left + 1;
  if (ind <= mid)
    update(left, l, mid, ind, val);
  else
    update(right, mid + 1, r, ind, val);
  tree[node] = max(tree[left], tree[right]);
  return;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  vector<int> temp;
  temp.clear();
  cin >> n;
  A[0] = 1;
  for (int i = 1; i <= n; i++) {
    cin >> A[i];
    A[i] -= i;
    temp.push_back(A[i]);
  }
  sort(temp.begin(), temp.end());
  int pt = 1;
  for (int i = 0; i < temp.size(); i++) {
    if (M[temp[i]] == 0) {
      M[temp[i]] = pt;
      revM[pt] = temp[i];
      pt++;
    }
  }
  for (int i = 1; i <= n; i++) {
    A[i] = M[A[i]];
    pre[i] = query(1, 0, pt, 0, A[i]) + 1;
    update(1, 0, pt, A[i], pre[i]);
  }
  build(1, 0, pt);
  int ans = n - pre[n - 1] - 1;
  for (int i = n - 1; i > 0; i--) {
    suf[i + 1] = query(1, 0, pt, A[i + 1], pt) + 1;
    update(1, 0, pt, A[i + 1], suf[i + 1]);
    if (M[revM[A[i - 1]] - 1] == 0)
      ans = min(ans, n - 1 - pre[i - 1] - query(1, 0, pt, A[i - 1], pt));
    else
      ans = min(ans, n - 1 - pre[i - 1] - query(1, 0, pt, A[i - 1] - 1, pt));
  }
  cout << ans << "\n";
  return 0;
}
