What's wrong with this code

Hey @Narasimha
code is fine
Just a changes
take array type of long instead of int
correct code :
import java.util.*;
public class Main
{
public static long helper(long[] heights, int left, int right) {
if (left > right) return 0;
if (left == right) return heights[left];
int minIndex = 0; long min = Long.MAX_VALUE;
for (int i = left; i <= right; i++) {
if (heights[i] < min) {
min = heights[i];
minIndex = i;
}
}

  long maximumWidthArea = (right - left + 1) * min;
  long leftAreaMax = helper(heights, left, minIndex - 1);
  long rightAreaMax = helper(heights, minIndex + 1, right);
  
  return Math.max(maximumWidthArea, Math.max(leftAreaMax, rightAreaMax));

}
public static void main(String[] args)
{
Scanner obj=new Scanner(System.in);
int n=obj.nextInt();
long a[]=new long[n];
for(int i=0;i<n;i++)
{
a[i]=obj.nextLong();
}
System.out.println(helper(a,0,a.length-1));
}
}