Distributing the Money#11291

Distributing the Money

1 second
512 megabytes
Hard

Huseyn and his younger brother found a wallet with banknotes on the street. Since the owner of the money could not be found, they decided to divide the money among themselves. They divided the money among themselves so that everyone got the same amount of money. After dividing the money equally, if there is any remainder that cannot be divided, Huseyn takes it because he is the oldest brother.

Determine the amount of money that Huseyn got.

Input

The first line contains an integer n~(1 \le n \le 500) — the number of banknotes in the wallet. Each of the following lines contains one positive integer value c_i — the value of the -th banknote (in manats). It is known that c_1 + ... + c_n \le 10^5.

Output

Print the amount of money that Huseyn got.

Examples

Example 1. Huseyn can take the banknote of manats, and his brother can take the rest of the banknotes.

Example 2. In the initial distribution, Huseyn can take a banknote of manats, and his brother can take a banknote of manats and manats. In this case, a banknote with value of manats goes to Huseyn. Thus, Huseyn receives 19 + 3 = 22 manats.

Example 1

Loading
Loading

Example 2

Loading
Loading