Codeforces Round 676 (Div. 2)
E
Swedish Heroes
Codeforces
2700
原题
← D→
翻译中…

While playing yet another strategy game, Mans has recruited $n$ Swedish heroes, whose powers which can be represented as an array $a$.

翻译中…

Unfortunately, not all of those mighty heroes were created as capable as he wanted, so that he decided to do something about it. In order to accomplish his goal, he can pick two consecutive heroes, with powers $a_i$ and $a_{i+1}$, remove them and insert a hero with power $-(a_i+a_{i+1})$ back in the same position.

翻译中…

For example if the array contains the elements $[5, 6, 7, 8]$, he can pick $6$ and $7$ and get $[5, -(6+7), 8] = [5, -13, 8]$.

翻译中…

After he will perform this operation $n-1$ times, Mans will end up having only one hero. He wants his power to be as big as possible. What's the largest possible power he can achieve?

翻译中…

Input

翻译中…

The first line contains a single integer $n$ ($1 \le n \le 200000$).

翻译中…

The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($-10^9 \le a_i \le 10^9$) — powers of the heroes.

翻译中…

Output

翻译中…

Print the largest possible power he can achieve after $n-1$ operations.

翻译中…

Note

翻译中…

Suitable list of operations for the first sample:

翻译中…

$[5, 6, 7, 8] \rightarrow [-11, 7, 8] \rightarrow [-11, -15] \rightarrow [26]$

翻译中…

样例

Input #1
4
5 6 7 8
Output #1
26
InputCopy OutputCopy
Input #2
5
4 -5 9 -2 1
Output #2
15
InputCopy OutputCopy
题目信息
题号
1421E
时间限制
2 s
内存限制
256 MB
标签
暴力
动态规划
模拟

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。