Hide

Problem C
Outlets

/problems/cuhs.outlets/file/statement/en/img-0001.jpeg
Cats like lasers
You’ve acquired a large number of rechargeable laser pointers to entertain the cats Mister Blue, Coriander, and Skimpy. Then you got home and realized that there is a single outlet available!

Fortunately you have some power cords. The $i$-th cord can power $a_ i$ devices (including other power cords).

You want to know how many lasers can be recharged simultaneously.

Input

The first line of input contains an integer $N$ ($1 \le N \le 10\, 000$) containing the number of power cords.

Each of the next $N$ lines contain a single integer containing the number of devices a particular cord can power. $0 \le a_ i \le 1\, 000$.

Output

Output a single integer with the maximum number of lasers you can recharge at the same time. Note that you don’t need to use all the power cords.

Sample Input 1 Sample Output 1
1
10
10
Sample Input 2 Sample Output 2
3
5
6
7
16

Please log in to submit a solution to this problem

Log in