#K83102. Minimum Sequence Sum Adjustment
Minimum Sequence Sum Adjustment
Minimum Sequence Sum Adjustment
You are given a sequence of n integers. You are permitted to perform exactly one operation on the sequence: either increment or decrement any one element by 1. Your task is to compute the minimum possible sum of the sequence after this operation is applied.
Formally, let \(S\) be the sum of the given sequence. By applying the operation (either \(+1\) or \(-1\) on one element), the possible new sums become \(S+1\) and \(S-1\). Since we want the minimum sum, the answer is \(S-1\).
Input Restrictions: The first line of input contains the integer \(n\) denoting the number of elements in the sequence. The second line contains \(n\) space-separated integers.
inputFormat
The input is given from stdin with the following format:
- The first line contains a single integer \(n\) (the number of elements in the sequence).
- The second line contains \(n\) space-separated integers representing the sequence.
outputFormat
Output the minimum sum achievable after performing exactly one operation on the sequence. Print the result to stdout.
Formally, if \(S\) is the sum of the sequence, output \(S - 1\).
## sample5
1 2 3 4 5
14
</p>