For this Question: Given n non-negative integers representing an elevation map where the width of each bar is 1, compute volume of water it is able to trap after raining.
Please refer to Sample test case for more details.The first line of input contains the size of the array, n
The following line of input contains n space-separated integers

Constraints:-
1 <= n <= 50000
0<=A[i]<=10<sup>10</sup>The first and only line of output contains integer, in accordance to the task.Sample Input:
6
3 0 0 2 0 4
Sample Output:
10, I have written this Solution Code: import java.io.*;
import java.util.*;
import java.text.DecimalFormat;



class Main {
	public static void main (String[] args)throws IOException {

				      BufferedReader y = new BufferedReader(new InputStreamReader(System.in));
					  int n = Integer.parseInt(y.readLine());
					  String [] z = y.readLine().split(" ");
					  long max = 0;
					  long sum = 0;
					  int si = 0;
					  int ei = 0;
					  for (int i=0;i<n;i++){
						  long num = Long.parseLong(z[i]);
						  if (max==0 && num!=0){
							  max=num;
							  si=i;
						  }else if (num>=max){
							  ei=i;
							  sum+=count(z,si,ei);
							  si=i;
							  max=num;
						  }
					  }
					  while (si<n-1){
						  ei=findmax(z,si+1,n);
						  sum+=count(z,si,ei);
						  si=ei;
					  }
					  System.out.println(sum);
	}
	public static long count(String z[], int si, int ei){
		long num = Math.min(Long.parseLong(z[si]),Long.parseLong(z[ei]));
		si++;
		long count=0;
		for (int i=si;i<ei;i++){
			count+=(num-Long.parseLong(z[i]));
		}
		return count;
	}
	public static int findmax(String z[], int si, int n){
		long max = Long.parseLong(z[si]);
		int ind = si;
		for (int i=si;i<n;i++){
			if (max<=Long.parseLong(z[i])){
				max=Long.parseLong(z[i]);
				ind = i;
			}
		}
		return ind;
	}
}, In this Programming Language: Java, Now tell me if this Code is compilable or not?