#include using namespace std; #define incID(i, l, r) for(int i = (l) ; i < (r); i++) #define inc(i, n) incID(i, 0, n) #define ALL(v) v.begin(), v.end() // ---- ---- int n, a[200000], INF = 2e9; int main() { cin >> n; inc(i, n) { cin >> a[i]; } vector dp(n + 1, INF); dp[0] = 0; inc(i, n) { if(a[i] >= i) { * lower_bound(ALL(dp), a[i] - i) = a[i] - (i + 1); } } cout << count(ALL(dp), INF) << endl; return 0; }