#K81387. Minimum Sum After Segment Reversal
Minimum Sum After Segment Reversal
Minimum Sum After Segment Reversal
You are given an array of n
integers. You are allowed to reverse exactly one continuous segment of the array. Note that reversing any segment does not change the overall sum of the array. Your task is to compute the minimum possible sum of the elements after performing this operation.
Observation: Reversing a segment of an array retains the sum of its elements, so the answer is simply the sum of all the elements in the array.
In this problem, you need to implement a solution which reads input from stdin
and outputs the answer to stdout
.
inputFormat
The first line contains a single integer n
(0 ≤ n ≤ 105), representing the number of elements in the array.
The second line contains n
space-separated integers, which are the elements of the array.
outputFormat
Output a single integer which is the sum of the elements of the array.
## sample5
1 2 3 4 5
15
</p>