#include using namespace std; int solve() { int n; cin >> n; vector A; for (int i = 0; i < n; i++) { int a; cin >> a; if (a - i > 0) { A.emplace_back(a - i); } } int m = A.size(); const int inf = 1e9; vector dp(m + 1, inf); for (int i = 0; i < m; i++) *upper_bound(dp.begin(), dp.end(), A[i]) = A[i]; int lis = lower_bound(dp.begin(), dp.end(), inf) - dp.begin(); return n - lis; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << solve() << endl; return 0; }