402583: GYM100812 J Feeling of Comradeship

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

J. Feeling of Comradeshiptime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

I was tired. Tired of hiding and wandering. Throw the rules out the window, odds are you'll go that way too. I just wanted everything to be finished. The crying heavens had already given a verdict for me, I was just looking for somebody to execute it. The castle of Dragon was not defenseless, it was ready for my visit. The beast inside me was woking up and rubbing his eyes.

I had already known every single bandit guarding Dragon's castle. It was quite useful to have connections in knight orders. There were only n men there. There had been some bigger frays. And not all of them desperately wanted to die by my hand that night. I knew that the i-th of them would have decided to fight only if at least ai other bandits had decided the same. I was slowly approaching the gates, wondering what was the maximal number of people who might have opposed me.

Input

The first line contains a single integer n (1 ≤ n ≤ 105) — the number of bandits in the castle of Dragon.

The second line contains n integers separated by spaces: ai (0 ≤ ai ≤ 109) — the minimal number of other bandits with whom together the i-th bandit is ready to fight.

Output

Output a single integer — the maximal number of bandits that might be ready to fight for Dragon's castle.

ExamplesInput
6
4 2 1 6 0 3
Output
5
Input
6
1 3 6 1 3 5
Output
4

加入题单

算法标签: