Lemonade Line

Given each cow's maximum tolerated queue length, choose an arrival order that minimizes how many cows end up waiting in line.

Medium4GreedySortingArrayImplementationInterviewNo attempts yetTime limit2sMemory limit512 MB

Problem

It is a hot summer day on the farm, and Farmer John is serving lemonade to his NN cows. Every cow likes lemonade, but some like it more than others. The cows are numbered 11 through NN, and cow ii is willing to wait in line behind at most wiw_i other cows to get her lemonade.

Right now all NN cows are out in the fields. As soon as Farmer John rings his cowbell, the cows head straight for the lemonade stand. They all arrive before he starts serving, and no two cows arrive at the same time. When cow ii arrives, she joins the line if and only if at most wiw_i cows are already in it. Otherwise she turns away.

Farmer John wants to prepare the lemonade in advance without wasting any. The number of cows who join the line depends on the order in which they arrive. Find the smallest number of cows who can end up in the line.

Input

The first line contains NN. The second line contains the NN space separated integers w1,w2,,wNw_1, w_2, \dots, w_N. It is guaranteed that 1N1051 \leq N \leq 10^5 and that 0wi1090 \leq w_i \leq 10^9 for each cow ii.

Output

Print, on one line, the smallest number of cows who join the line, taken over all possible arrival orders.

Note

In the first example only three cows end up in line, and no arrival order does better. Suppose the cows with w=7w = 7 and w=400w = 400 arrive first and wait in line. The cow with w=1w = 1 then arrives and turns away, since two cows are already in line. The two cows with w=2w = 2 arrive last, one staying and one turning away.