#include using namespace std; template class Array : public vector { public: using vector::vector; using vector::begin; using vector::end; using vector::push_back; template Array map(function f) { Array res(end() - begin()); for (auto it = begin(); it != end(); ++it) res[it - begin()] = f(*it); return res; } Array select(function f) { Array res; for (auto it = begin(); it != end(); ++it) if (f(*it)) res.push_back(*it); return res; } template R reduce(R u, function f) { for (auto it = begin(); it != end(); ++it) u = f(u, *it); return u; } template Array> zip(const Array &b) { assert(end() - begin() == b.end() - b.begin()); Array> res; for (auto it = begin(); it != end(); ++it) res.push_back({*it, b[it - begin()]}); return res; } Array iota(T st) { Array res(end() - begin()); ::iota(res.begin(), res.end(), st); return res; } }; signed main() { ios::sync_with_stdio(false); int N; cin >> N; Array A(N); for (int i = 0; i < N; ++i) cin >> A[i]; Array a = A.zip(Array(N).iota(0)) .template map([](pair p) { return p.first - p.second; }) .select([](int x) { return 0 < x; }); Array dp(N, 0x3f3f3f3f); for (int v : a) *upper_bound(dp.begin(), dp.end(), v) = v; size_t lis = lower_bound(dp.begin(), dp.end(), 0x3f3f3f3f) - dp.begin(); cout << N - lis << endl; return 0; }