#ABC472B. 折断木棍 / Break a Stick

折断木棍 / Break a Stick

Problem Statement

There is one stick. This stick has N1N-1 notches, which divide it into NN parts.

The lengths of the parts are L1,L2,,LNL_1,L_2,\dots,L_N in order from one end.

When choosing one notch and breaking the stick there to obtain two sticks, find the minimum possible absolute value of the difference between the lengths of the two resulting sticks.

Here, the width of a notch can be ignored, and the length of each resulting stick is the sum of the lengths of the parts it contains.

Constraints

  • 2N1002 \leq N \leq 100
  • 1Li1051 \leq L_i \leq 10^5
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

  • NN
  • L1L_1 L2L_2 \dots LNL_N

Output

Output the answer.

4
5 2 3 8
2

Breaking the stick at each notch results in the following:

  • Breaking at the first notch from the end results in two sticks of lengths 55 and 1313, with an absolute difference of 88.
  • Breaking at the second notch from the end results in two sticks of lengths 77 and 1111, with an absolute difference of 44.
  • Breaking at the third notch from the end results in two sticks of lengths 1010 and 88, with an absolute difference of 22.
7
31 41 59 26 53 58 97
51
10
67011 35764 33042 24098 63738 98760 17199 68579 21812 45408
28105