Firewood Pile

No attempts yetTime limit1sMemory limit1024 MB

Problem

Adomas is getting ready for winter and has bought $N$ logs of firewood. All the logs have the same diameter, but they may have different lengths. Adomas wants to stack all of them in his cellar.

He builds the pile like this:

  1. He lays the first log flat on the floor.
  2. On top of it he lays as many logs as possible, each placed crosswise (perpendicular) to the log below. A log of length $L$ can support at most $L$ logs laid across it.
  3. On top of that layer he lays a single log again, crosswise to the logs beneath it. This single log may be no longer than the number of logs directly below it.
  4. On top of that single log he again lays as many crosswise logs as possible, and so on — alternating between one single log and one full crosswise layer.

An example of a firewood pile

Figure 1. An example of a firewood pile.

All logs share the same diameter, so every layer has the same thickness. The height of the pile is therefore the number of layers it consists of: each single log counts as one layer, and each crosswise group of logs counts as one layer.

Adomas is not very tall, so he wants the pile to be as low as possible. Given the lengths of all the logs, find the smallest possible height of the pile built in the described way.

Input

The first line contains the number of logs $N$.

The second line contains $N$ space-separated integers $L_i$ — the lengths of the logs.

Output

Print a single integer — the smallest possible height of the firewood pile.

Constraints

  • $1 \le N \le 10^6$
  • $1 \le L_i \le 10^6$ (for $1 \le i \le N$)