#JBIRDS. Jeremías y sus loros
Jeremías y sus loros
The pirate Jeremiah plans to offer a show to his crew. For this, Jeremiah has N parrots, which he plans to balance on his shoulders. Each of the N parrots has a weight, in grams, which Jeremiah knows beforehand.
Jeremiah has only two shoulders, and therefore he must separate the parrots into two groups. The imbalance of Jeremiah will be equal to the (positive) difference in weight between the group that leads on the left shoulder and the one on the right shoulder.
What is the lowest value that the pirate's imbalance can take?
Input
The entry begins with a line containing a single integer, N (0 <= N <= 10000)
The following N lines describe the weights of the parrots. Each line contains a single integer wi (0 <= wi <= 1000)
Output
A line with a single integer, the minimum imbalance (in absolute value).
Example
Input: 4 2 1 5 3</p>Output: 1