#K66072. Maximized Sequence Sum After Two Reversals

    ID: 32339 Type: Default 1000ms 256MiB

Maximized Sequence Sum After Two Reversals

Maximized Sequence Sum After Two Reversals

Alice and Bob are allowed to each perform an operation on an integer sequence. In each operation, they can choose any contiguous subarray and reverse it, which has the special effect of flipping the sign of all elements in that subarray. Note that the reversal does not change the order of absolute values, but it can turn negative numbers into positives.

Your task is to compute the maximum possible sum of the sequence after exactly two such operations. It turns out that with two operations, it is always possible to achieve the sum of the absolute values of each element. Mathematically, you need to compute:

Maximum Sum=i=1nai\text{Maximum Sum} = \sum_{i=1}^{n} |a_i|

where \(a_i\) are the elements of the sequence.

inputFormat

The first line of input contains an integer \(n\) representing the number of elements in the sequence. The second line contains \(n\) space-separated integers representing the sequence.

outputFormat

Output a single integer, the maximum possible sum of the sequence after the two reversal operations.

## sample
4
1 2 -3 4
10

</p>