ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

2183. Good Mood

Time limit: 1.0 second
Memory limit: 256 MB
Doctor Livesey cares not only about the physical but also about the psychological state of the crew. To make the crew feel happier, the doctor decided to reduce the level of negativity. There are n people on the ship, and the mood of each can be described by an integer ai.
Doctor Livesey does not yet have enough experience, so he can only improve the mood of one group of people. By choosing a subsegment of people, the doctor changes their mood to the opposite. Formally, this means that he selects two numbers 1 ≤ lrn and changes the signs of all values ai on the segment [l; r].
The effectiveness of the team is determined by the mood of the most unhappy person, so the captain set the doctor the task of choosing such a segment of people that the minimum mood among all team members becomes as high as possible.
Problem illustration

Input

The first line of input contains a natural number n — the number of team members (1 ≤ n ≤ 105).
The second line of input contains an array of integers a of length n — the mood of each team member, where ai is the mood of the i-th person (−109ai ≤ 109). It is guaranteed that there exists at least one ai < 0.

Output

Output a single number — the highest possible value of the minimum mood in the team after the change.

Samples

inputoutput
5
-1 3 -2 -4 5
-1
4
2 -4 -3 -10
2

Notes

In the first example, one can choose the segment [3; 4], then the moods of the people will be [−1, 3, 2, 4, 5].
Problem Author: Artyom Abaturov
Problem Source: Ural School Programming Contest 2024