A. Snacks within 300 Yen
time limit per test
5 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output

Your friend, Greedy George, visits a candy store for his snacks for the school excursion, grabbing 300 yen in his hand. In the candy store, one item of each different kind of snack is placed in a line on the shelf. After entering the store, Greedy George picks up a shopping basket and starts checking the snacks on the shelf from left to right. If the sum of the prices of snacks in the basket will not exceed 300 yen, he immediately puts the checked snack into the basket. If the sum should exceed 300 yen, he tearfully skips that snack. After examining all the snacks in this manner to the right end, George heads to the checkout.

Given a list of the prices of the snacks in the store, compute how much money Greedy George will spend.

Figure A-1: The first dataset of Sample Input
Input

The input consists of multiple datasets, each in the following format. The number of datasets does not exceed $$$50$$$.

$$$n$$$
$$$a_1$$$ $$$a_2$$$ $$$\ldots$$$ $$$a_n$$$

$$$n$$$ ($$$1 \le n \le 100$$$) is the number of snacks sold in the candy store. $$$a_k$$$ ($$$k = 1, \ldots, n$$$) is a positive integer less than or equal to $$$1000$$$, meaning that the price of the $$$k$$$-th snack from the left is $$$a_k$$$ yen.

The end of the input is indicated by a line consisting of a zero.

Output

For each dataset, output in a line how many yen Greedy George will spend on the snacks.

Example
Input
5
100 50 200 120 60
4
120 240 180 1
2
500 1000
6
2 3 5 7 11 13
0
Output
270
300
0
41