#include using namespace std; #define rep(i,n) for(int i=0; i<(n); i++) int N; int A[100000]; int LIS[100002]; 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) { 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; }