LearnPy Hub
← Arena
AdvancedRating 1500

Most Water

Heights of vertical lines are given. Choose two lines that, with the x-axis, hold the most water: (j − i) × min(h[i], h[j]). Print that amount.

Input

n, then n heights.

Output

A number.

Sample 1

Input
9
1 8 6 2 5 4 8 3 7
Output
49

Sample 2

Input
2
1 1
Output
1
solution.py
Output appears here
Most Water · Python Arena problem · LearnPy Hub