OpenKattis
popup15 problemsession 1

#### Start

2015-09-25 03:15 AKDT

## popup15 problemsession 1

#### End

2015-09-25 07:45 AKDT
The end is near!
Session is over.
Not yet started.
Session is starting in -2258 days 23:01:27

4:30:00

0:00:00

# Problem GWalrus Weights

Wallace the Weightlifting Walrus is training for a contest where it will have to lift $1\, 000$ kg. Wallace has some weight plates lying around, possibly of different weights, and its goal is to add some of the plates to a bar so that it can train with a weight as close as possible to $1\, 000$ kg.

In case there exist two such numbers which are equally close to $1\, 000$ (e.g. $998$ and $1\, 002$), Wallace will pick the greater one (in this case $1\, 002$).

Help Wallace the Weightlifting Walrus and tell it which weight it will have to lift.

## Input

The first line of the input contains the number of plates $n$ ($1 \leq n \leq 1\, 000$). Each of the following $n$ lines contains one positive integer less than or equal to $1\, 000$, denoting the weight of each plate.

## Output

Output one integer, the combined weight closest to $1\, 000$.

Sample Input 1 Sample Output 1
4
900
500
498
4

1002

Sample Input 2 Sample Output 2
1
1

1