100 atcoder#ABC125D. [ABC125D] Flipping Signs
[ABC125D] Flipping Signs
Score : points
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 .
3
-10 5 -4
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.
5
10 -4 -8 -11 3
30
11
-1000000000 1000000000 -1000000000 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000
10000000000
The output may not fit into a -bit integer type.