• # For Solution

Two Posters solution codeforces:- You want to advertise your new business, so you are going to place two posters on a billboard in the city center. The billboard consists of nn vertical panels of width 11 and varying integer heights, held together by a horizontal bar. The ii-th of the nn panels has height hihi.

Initially, all panels hang down from the bar (their top edges lie on it), but before placing the two posters, you are allowed to move each panel up by any integer length, as long as it is still connected to the bar (its bottom edge lies below or on it).

After the moves are done, you will place two posters: one below the bar and one above it. They are not allowed to go over the bar and they must be positioned completely inside of the panels.

What is the maximum total area the two posters can cover together if you make the optimal moves? Note that you can also place a poster of 00 area. This case is equivalent to placing a single poster.

Input

## Two Posters solution codeforces

The first line of input contains one integer nn (1n1041≤n≤104) — the number of vertical panels.

The second line of input contains nn integers h1,h2,...,hnh1,h2,…,hn (1hi10121≤hi≤1012) — the heights of the nn vertical panels.

## Two Posters solution codeforces

Print a single integer — the maximum total area the two posters can cover together.

Examples

input

Copy
6
2 2 3 5 4 5


output

Copy
18


input

Copy
1
1


## Two Posters solution codeforces

Copy
1

Note

In the first sample test, we can choose an upper poster with area 1212 and a lower poster of area 66 as in the image below.

In the second sample test, we can cover the whole billboard using a single poster.