#C7370. Minimize Subset Difference
Minimize Subset Difference
Minimize Subset Difference
Given a list of n integers, your task is to divide the list into two non-empty subsequences such that the absolute difference between the sums of the two subsequences is minimized. Formally, let the total sum of the list be \(T\) and let \(s\) be the sum of one non-empty subsequence (with the other subsequence summing to \(T-s\)). You are to find the minimum possible value of the difference:
[ |T - 2s|, ]
Note that both subsequences must be non-empty: you are not allowed to consider \(s=0\) or \(s=T\).
inputFormat
The first line of input contains a single integer n representing the number of integers in the list. The second line contains n space-separated integers.
outputFormat
Output a single integer denoting the minimum absolute difference between the sums of the two non-empty subsequences.
## sample4
1 5 11 5
0