Codeforces Beta Round 33(Codeforces 格式)
C
奇妙的随机化求和
Wonderful Randomized Sum
Codeforces
1800
原题
← BD →

奇妙的随机化求和AI (CI翻译)

Learn, learn and learn again — Valera has to do this every day. He is studying at mathematical school, where math is the main discipline. The mathematics teacher loves her discipline very much and tries to cultivate this love in children. That's why she always gives her students large and difficult homework. Despite that Valera is one of the best students, he failed to manage with the new homework. That's why he asks for your help. He has the following task. A sequence of $*n*$ numbers is given. A prefix of a sequence is the part of the sequence (possibly empty), taken from the start of the sequence. A suffix of a sequence is the part of the sequence (possibly empty), taken from the end of the sequence. It is allowed to sequentially make two operations with the sequence. The first operation is to take some prefix of the sequence and multiply all numbers in this prefix by $- 1$. The second operation is to take some suffix and multiply all numbers in it by $- 1$. The chosen prefix and suffix may intersect. What is the maximum total sum of the sequence that can be obtained by applying the described operations?

翻译中…

Input

输入格式

AI (CI翻译)

The first line contains integer $*n*$ ($1 ≤ *n* ≤ 10^{5}$) — amount of elements in the sequence. The second line contains $*n*$ integers $*a*_{*i*}$ ($- 10^{4} ≤ *a*_{*i*} ≤ 10^{4}$) — the sequence itself.

第一行包含一个整数 $*n*$($1 ≤ *n* ≤ 10^{5}$),表示序列中元素的个数。第二行包含 $*n*$ 个整数 $*a*_{*i*}$($- 10^{4} ≤ *a*_{*i*} ≤ 10^{4}$),表示该序列。AI (CI翻译)

Output

输出格式

AI (CI翻译)

The first and the only line of the output should contain the answer to the problem.

输出一行,包含题目的答案。AI (CI翻译)

样例

Input #1
3
-1 -2 -3
Output #1
6
InputCopy OutputCopy
Input #2
5
-4 2 0 5 0
Output #2
11
InputCopy OutputCopy
Input #3
5
-1 10 -5 10 -2
Output #3
18
InputCopy OutputCopy
题目信息
题号
33C
时间限制
2 s
内存限制
256 MB
标签
贪心

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