Max Sum In The Configuration

medium
1. Given an array, you have to find the max sum of i*A[i] where A[i] is the element at index i in the array. 
2. The only operation allowed is to rotate(clock-wise or counter clock-wise) the array any number of times.

Input Format

Input is managed for you

Output Format

Output is managed for you

Constraints

1 <= N <= 10^6
1 <= arr[i] <= 10^5

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
4
8 3 1 2
Output
29
Previous
Find First And Last Postion Of Element In Sorted Array
Next
Median Of Two Sorted Arrays

Related Questions