Under construction

Still being built. Things may change

H-Index

Interview

Time limit1sMemory limit256 MB

Summary
Given N citation counts, compute the largest H with at least H papers cited at least H times.
Level

Easy3 of 10

Topics
Sorting
Solved
No attempts yet

Problem

How do you measure a scientist's success? You can count the papers they published, or you can count the impact of those papers, that is, how often other scientists cite them. Both numbers matter. A paper has citation score CC if other scientists cited it CC times in their own papers. The h-index is one metric that reflects the number of papers and their citation scores at the same time.

The h-index is the largest integer HH with the following property: the scientist can choose HH papers whose citation score is at least HH. For example, if a scientist wrote 10 papers and each of them was cited 10 or more times, that scientist's h-index is at least 10.

Given the citation scores of every paper a scientist wrote, write a program that computes the h-index.

Input

The first line contains the number of papers NN (1≤N≤500,0001 \le N \le 500{,}000).

The second line contains NN citation scores separated by spaces. Each citation score is an integer between 00 and 1,000,0001{,}000{,}000.

Output

Print the h-index on the first line.

Hint

In the first example two papers have a citation score of 2 or more, the one cited 4 times and the one cited 8 times. Only one paper has a citation score of 3 or more, so the h-index is 2.

Examples2

  1. Example 1

    Input
    5
    1 1 4 8 1
    
    Expected output
    2
    
  2. Example 2

    Input
    5
    8 5 3 4 10
    
    Expected output
    4