~/algor $ cat problems/saralash-xirsh-indeksi
h-index
Medium
1000 ms
128 MB
51%
A scientist has $n$ papers, the $i$-th paper has been cited $c_{i}$ times. The scientist's h-index (Hirsch index) is the largest number $h$ such that at least $h$ of the papers have each been cited at least $h$ times. Find the h-index.
Input
The first line contains a positive integer $n$. The second line contains $n$ integers $c_{i}$.
Output
One integer — $h$.
Note
$1 \le n \le 2 \cdot 10^{5}$
$0 \le c_{i} \le 10^{9}$
Examples
Input #1
5 3 0 6 1 5
Output #1
3
Input #2
1 0
Output #2
0