#include #include using namespace std; const int INF = 1<<30; int n; int a[200000]; int dp[200000]; int main(int argc, char *argv[]) { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; a[i] -= i; } fill(dp, dp + n, INF); for (int i = 0; i < n; i++) { *upper_bound(dp, dp + n, a[i]) = a[i]; } int ret = lower_bound(dp, dp + n, INF) - dp; cout << n - ret << endl; return 0; }