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$
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\,
Help Wallace the Weightlifting Walrus and tell it which
weight it will have to lift.
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 one integer, the combined weight closest to
|Sample Input 1
||Sample Output 1
|Sample Input 2
||Sample Output 2