#include #include #pragma warning(disable : 4996) int n, x, d[100009]; int main() { scanf("%d", &n); for (int i = 0; i < n; ++i) { scanf("%d", &x); d[i] = 1 << 30; if (x - i > 0) *std::lower_bound(d, d + i, x - i + 1) = x - i; } printf("%d\n", n - (std::lower_bound(d, d + n, 1 << 30) - d)); return 0; }