#include using namespace std; using LL = long long; using ULL = unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) int N; int A[200000]; int LIS[200002]; int main() { cin >> N; rep(i, N) cin >> A[i]; rep(i, N) A[i] -= i; rep(i, N + 2) LIS[i] = 2000000000; LIS[0] = -2000000000; rep(i, N) { if (A[i] < 0) continue; auto p = upper_bound(LIS, LIS + N + 2, A[i]); *p = A[i]; } int ans = 0; rep(i, N + 1) if (LIS[i] != 2000000000) ans = i; ans = N - ans; cout << ans << endl; return 0; }