405835: GYM102133 F Financial Reports

Memory Limit:64 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

F. Financial Reportstime limit per test1 secondmemory limit per test64 megabytesinputstandard inputoutputstandard output

Financial analysts of "WeRRich" company are working on a current annual report. They have n data points of company's shares fluctuations sorted by time stamps in chronological order. The analysts are required to compute the most wealthy period, i.e. a consecutive non-empty time interval, which has maximum sum of fluctuations within a year period.

Unfortunately, top management of the company is not satisfied with the annual report results, hence analysts have decided to adjust the report by swapping two fluctuations in the time series. It looks like a perfect crime, but financiers are not able to develop efficient enough algorithm to perform the plan. Now they have to ask software engineers to help them out. So they are required to determine the fluctuation indices to swap and a maximum fluctuation sum, which is possible to obtain as a result.

Input

First line contains positive integer n – a number of fluctuations of shares within a financial year.

Second line contains exactly n integers ai – values of fluctuations given in chronological order.

2 ≤ n ≤ 105
|ai| ≤ 109
Output

The maximal fluctuations sum during the most wealthy period should be printed in a first line.

Second line should contain two different numbers – indices of swapped fluctuations. If multiple solution exist, you may output any of them.

ExampleInput
5
1 -2 -3 4 -5
Output
5
4 2

加入题单

算法标签: