For this Question: Given an array <b>A</b> of N integers, For each i (1 ≤ i ≤ N) your task is to find the value of  x+y, 
where x is the largest number less than i such that A[x]>A[i] and (A[x] is the element present at position x.)
y is the smallest number greater than i such that A[y]>A[i]
If there is no x < i such that A[x] > A[i], then take x=−1. Similarly, if there is no y>i such that A[y]>A[i], then take y=−1.First line consists of a single integer denoting N.
Second line consists of N space separated integers denoting the array A.

Constraints:
1 ≤ N ≤ 1000000
1 ≤ A[i] ≤ 10000000000Print N space separated integers, denoting x+y for each i(1 ≤ i ≤ N)Sample Input
5
5 4 1 3 2

Sample Output
-2 0 6 1 3 

Explanation:-
For element 5:- x=-1(No element exist greater than 5 in left), y=-1 (No element exist greater than 5 in right)
For element 4:- x=1, y=-1 
For element 1:- x=2, y=4
For element 3:- x=2, y=-1
For element 2:- x=4, y=-1 

Sample Input
5
6 4 6 8 2

Sample Output
3 4 3 -2 3, I have written this Solution Code: import java.io.*;
import java.util.*;



class Main {
	static int maxleft(int a[],int pos)
	{
		if(pos==1)
		{
			return -1;
		}
		else
		{int max=a[pos];int s=-1;
            for(int i=pos-1;i>=0;i--)
			{
                         if(max<a[i])
						 {
							 s=i;
							  break;
						 }
			}
			if(s==pos)
			{
				return -1;
			}
			else
			{
				return s;
			}
		}
}
	static int maxright(int a[],int pos,int n)
	{

		   int max=a[pos];
		   int s=-1;
		   if(pos==n)
		   {
			   return -1;
		   }
           else
		   { for(int i=pos+1;i<=n;i++)
			{
                         if(max<a[i])
						 {
							 s=i;
							 break;
						 }
			}
			if(s==pos)
			{
				return -1;
			}
			else
			{
				return s;
			}
			}
	}
	public static void main (String[] args) throws IOException{
                    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
					int n=Integer.parseInt(br.readLine());
					int a[]=new int[n+1];
					StringTokenizer st=new StringTokenizer(br.readLine()," ");
	                for(int i=1;i<n+1;i++)
					{
						a[i]=Integer.parseInt(st.nextToken());
					}
					for(int i=1;i<n+1;i++)
					{
						int maxl=maxleft(a,i);
						int maxr=maxright(a,i,n);
						System.out.print((maxl+maxr)+" ");

					}
	}
}, In this Programming Language: Java, Now tell me if this Code is compilable or not?