View as PDF

Submit solution

Points: 3
Time limit: 1.0s
Memory limit: 16M

Problem type
Vincent Massey SS - 2014 Senior Contest #1

Firebending is the element of power. Firebenders use their energy to create bursts of fire in order to overwhelm their opponent. As a result, they want to maximize the value of each fire blast that they shoot. In order to do so, they must revisit the art of mathematics.

You will be given n integers, one per line. For each of the integers, k_{i}, you can either keep it as k_{i}, or change it to -k_{i}. Find the maximum possible final sum of all the integers.

Input Specification

The first line contains the integer n (1 \le n \le 100\,000).
The next n lines will contain the integers k_{i}.

Output Specification

The largest possible final sum of the n integers.

Sample Input


Sample Output



Keep 1.
Change -2 to 2.
Keep 3.
Thus, the answer is 1 + 2 + 3 = 6.


  • -9
    Pandemic  commented on Sept. 27, 2020, 11:26 a.m.

    This comment is hidden due to too much negative feedback. Click here to view it.