#P6276. Easy $h$-index

    ID: 5144 远端评测题 1000ms 32MiB 尝试: 0 已通过: 0 难度: (无) 上传者: 标签>CCPC2018-湖南全国邀请赛-重现赛(感谢湘潭大学)

Easy $h$-index

Problem Description

比赛题目:
http://acm.hdu.edu.cn/downloads/2018ccpc_hn.pdf

The $h$-index of an author is the largest $h$ where he has at least $h$ papers with citations not less than $h$.

Bobo has published many papers.
Given $a_0, a_1, a_2, \dots, a_{n}$ which means Bobo has published $a_i$ papers with citations exactly $i$, find the $h$-index of Bobo.

Input

The input consists of several test cases and is terminated by end-of-file.

The first line of each test case contains an integer $n$.
The second line contains $(n+1)$ integers $a_0, a_1, \dots, a_n$.

Output

For each test case, print an integer which denotes the result.

## Constraint

* $1 \leq n \leq 2 \cdot 10^5$
* $0 \leq a_i \leq 10^9$
* The sum of $n$ does not exceed $250,000$.

1 1 2 2 1 2 3 3 0 0 0 0
1 2 0