import java.util.*;
import java.lang.*;
import java.io.*;
// The main method must be in a class named "Main".
class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int[] arr=new int[n];
for(int i=0;i<n;i++){
arr[i]=sc.nextInt();
}
int left=0,right=n-1;
int max_area=0;
while (left<right) {
int h=arr[left];
int w=arr[right];
int area=Math.min(h,w)*(right-left);
max_area=Math.max(area,max_area);
if(arr[left]<arr[right]) left++;
else right--;
}
System.out.println(max_area);
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: