#K11396. Maximum Subset Cost
Maximum Subset Cost
Maximum Subset Cost
You are given an array of n integers. Your task is to compute the maximum subset cost defined as the absolute value of the sum of the array elements. Mathematically, if the array is a and its sum is \( S = \sum_{i=1}^{n} a_i \), then the answer is \(|S|\). This is equivalent to considering one subset as the entire array and the other as an empty subset.
Note: The input guarantees that \( n \ge 2 \).
inputFormat
The first line contains an integer n (n ≥ 2), representing the number of elements in the array. The second line contains n space-separated integers.
outputFormat
Print a single integer representing the maximum subset cost (i.e. the absolute value of the sum of the array).## sample
5
1 2 3 4 5
15