#P2816. 宋荣子搭积木

宋荣子搭积木

Description

saruka loves building with blocks and has nn blocks. saruka’s blocks are special: they can only be stacked vertically one by one, and you may build many columns. Since saruka’s blocks are special, they are intelligent. The ii-th block has a mood value xix_i. If the total number of blocks stacked on top of this block exceeds xix_i, this block will be unhappy and vows never to play with saruka again. saruka loves blocks and will not make any block unhappy, but saruka also wants to use every block and minimize the number of columns. Can you help saruka?

Input Format

The first line contains an integer nn, as described above.
The second line contains nn numbers xix_i, as described above.

Output Format

Output a single integer, the minimum number of columns.

3
0 0 3

2
4
0 0 0 0

4

Hint

For 100%100\% of the testdata, 1n50001 \le n \le 5000, 0xin0 \le x_i \le n.

Translated by ChatGPT 5