Q-index

Given n citation counts, find the largest k such that at least k papers have k or more citations and the rest have at most k.

Medium4SortingArrayInterviewNo attempts yetTime limit1sMemory limit512 MB

Problem

ICPC University sets its doctoral graduation requirement from the number of papers a student has published and how often those papers are cited, and it measures this with a value called the q-index. Suppose a student has published nn papers, where n1n \ge 1. The student's q-index is kk when at least kk papers are cited kk or more times and each of the remaining nkn - k papers is cited at most kk times.

Take a student with 5 papers cited 8, 4, 5, 3, and 10 times. At least one paper is cited one or more times, but some of the other 4 papers are cited more than once, so the q-index is not 1. Fewer than 5 papers are cited 5 or more times, so it is not 5 either. Exactly 4 papers are cited 4 or more times and the one remaining paper is cited at most 4 times, so this student's q-index is 4.

Write a program that reads the citation counts of one student's papers and computes that student's q-index.

Input

The first line contains the number of papers nn the student published, where 1n10001 \le n \le 1000. The second line contains the citation counts of the nn papers in order, separated by spaces. Each citation count is an integer between 0 and 10000.

Output

Print the q-index on one line. The value is a non-negative integer.