Distance

No attempts yetTime limit1sMemory limit128 MB

Problem

You are given an array of integers. Choose two elements aa and bb from the array to maximize the value r=a+b+dr = a + b + d, where dd is the distance between the two elements' positions in the array, that is, the absolute difference of their indices. The two elements may be the same; if you pick the same element twice, that distance is 00. Find the maximum possible value of rr.

Input

The first line contains one integer nn (1n1061 \le n \le 10^6), the number of elements in the array. The second line contains nn integers a1,a2,,ana_1, a_2, \dots, a_n (1ai1091 \le a_i \le 10^9) separated by spaces, where aia_i is the ii-th element of the array.

Output

Print a single integer, the maximum value of rr.