cho.sh
Notes
Loading...

Plugs

Time limit

2s

Memory limit

256 MB

Problem

Sunyoung has only one wall outlet at home. She also has N power strips, and each power strip has a certain number of outlets.

If the power strips may be connected to one another so that they all receive power from the single wall outlet, what is the maximum number of computers that can be powered at the same time?

Input

The first line contains the number of power strips N (1 <= N <= 500,000).

Each of the next N lines contains a positive integer, the number of plugs that can be inserted into one power strip. Each integer is at most 1,000.

Output

Print one integer: the maximum number of computers that can be connected to power.