Given an array A of length N, your task is divide array into two non-empty subarray such that each of element present in the array must belong to exactly one subarray and the Good value is defined as the absolute difference between sum of both subarrays ( Let a be the sum of first subarray and b be the sum of second subarray , therefore it's Good Value is abs(a−b) ). Your task is to find the minimum possible Good Value of array A.
The first line contains N, the size of array A
The second line contains N space seperated integers, the elements of A
Output minimum Good Value possible for array A
2≤N≤2×105
1≤A[i]≤105
In the given test case, array A = { 6, 3, 7, 1, 2, 5 }
Two subarrays are {6, 3} and {7, 1, 2, 5}
Absolute difference between their sum is abs( (6+3) - (7+1+2+5) ) = abs(9-15) = 6