#C10401. Minimum Sweetness Difference

    ID: 39603 Type: Default 1000ms 256MiB

Minimum Sweetness Difference

Minimum Sweetness Difference

You are given a collection of n candies with various sweetness levels. Your task is to split the candies into two consecutive groups such that the absolute difference between the total sweetness of the left group and the right group is minimized.

Let \( S = [s_1, s_2, \dots, s_n] \) be the list of sweetness levels. If you split the list after the \( i\text{-th} \) candy (for \( 1 \le i < n \)), the left group will have a total sweetness \( L = s_1 + s_2 + \dots + s_i \) and the right group will have a total sweetness \( R = s_{i+1} + s_{i+2} + \dots + s_n \). You need to find the splitting position that minimizes \( |L - R| \).

Input and Output Format details are provided below.

inputFormat

The first line of input contains a single integer \( n \) representing the number of candies.

The second line contains \( n \) space-separated integers where each integer corresponds to the sweetness level of a candy.

Input is provided via standard input (stdin).

outputFormat

Print a single integer which is the minimum possible absolute difference between the sum of sweetness levels of the two consecutive groups.

Output should be printed to standard output (stdout).

## sample
5
1 3 2 4 2
0