XrkArul With Elden Ring (Easy Version)

TimeLimit:1000MS  MemoryLimit:256MB
64-bit integer IO format:%lld
未提交 | 登录后收藏
Problem Description

e7073b2a83f1eff7da86dfa14bccadc9ec3d43dd.jpg@942w_progressive.jpg

XrkArul is getting addicted to the game called Elden Ring,in which the world is on a line .There are n bosses on this line ,which XrkArul can get aexp if he beat the i th boss.


Now XrkArul can choose a boss among n bosses , and select a direction he moves (left or right) , in every second he will beat a boss.When XrkArul is on position i , he will beat the i th boss and get ai exp . Note that once he chooses a direction, he can only move to the end in one direction and can not turn back until he reaches one (left or right) end of the line. 


For every second, the other boss which are not beated will lose their exp by 1 (minimum to 0). Because XrkArul is a skilled gamer, he can always get the most exp in the end. 


Can you calculate the exp that XrkArul eventually gets? 


Note that once a boss is beated, he will no longer exist.

Input

The first line contains only integer n (1≤ n ≤1e6).


The second line contains n integers a1,a2,...,an  (0≤ ai ≤1e9).

Output

An integer , the exp that XrkArul eventually gets.

SampleInput
4
1 5 3 2
SampleOutput
7

Note:In this case,XrkArul can start at position 2 and choose to move right,this way the exp he can get is 5+2+0=7.
Submit
题目统计信息详细
总AC数9
通过人数7
尝试人数8
总提交量24
AC率29.17%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: