#abc125d. [abc125_d]Flipping Signs
[abc125_d]Flipping Signs
Problem Statement
There are integers, , arranged in a row in this order.
You can perform the following operation on this integer sequence any number of times:
Operation: Choose an integer satisfying . Multiply both and by .
Let be the integer sequence after your operations.
Find the maximum possible value of .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the maximum possible value of .
Sample Input 1
3
-10 5 -4
Sample Output 1
19
If we perform the operation as follows:
- Choose as , which changes the sequence to .
- Choose as , which changes the sequence to .
we have . The sum here, , is the maximum possible result.
Sample Input 2
5
10 -4 -8 -11 3
Sample Output 2
30
Sample Input 3
11
-1000000000 1000000000 -1000000000 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000
Sample Output 3
10000000000
The output may not fit into a -bit integer type.