B - Citation Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 200

問題文

長さ N の非負整数列 A=(A_1,A_2,\dots,A_N) が与えられます。次を満たす最大の非負整数 x を求めてください。

  • A に、 x 以上の要素が重複を含めて x 回以上現れる。

制約

  • 1 \leq N \leq 100
  • 0 \leq A_i \leq 10^9
  • 入力はすべて整数

入力

入力は以下の形式で標準入力から与えられる。

N
A_1 A_2 \dots A_N

出力

答えを出力せよ。


入力例 1

3
1 2 1

出力例 1

1

A=(1,2,1)

  • 0 以上の要素は 3
  • 1 以上の要素は 3
  • 2 以上の要素は 1
  • 3 以上の要素は 0

現れます。条件を満たす最大の非負整数は 1 です。


入力例 2

7
1 6 2 10 2 3 2

出力例 2

3

Score : 200 points

Problem Statement

You are given a sequence of non-negative integers A=(A_1,A_2,\dots,A_N) of length N. Find the maximum non-negative integer x that satisfies the following:

  • In A, elements greater than or equal to x appear at least x times (including duplicates).

Constraints

  • 1 \leq N \leq 100
  • 0 \leq A_i \leq 10^9
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

N
A_1 A_2 \dots A_N

Output

Output the answer.


Sample Input 1

3
1 2 1

Sample Output 1

1

In A=(1,2,1):

  • Elements greater than or equal to 0 appear 3 times.
  • Elements greater than or equal to 1 appear 3 times.
  • Elements greater than or equal to 2 appear 1 time.
  • Elements greater than or equal to 3 appear 0 times.

The maximum non-negative integer that satisfies the condition is 1.


Sample Input 2

7
1 6 2 10 2 3 2

Sample Output 2

3