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: n=int(input())
arr=list(map(int,input().split()))
stk=[[arr[0],0]]
x=[-1]
for i in range(1,len(arr)):
	if stk[-1][0]>arr[i]:
		x.append(stk[-1][1]+1)
		stk.append([arr[i],i])
	else:
		while stk and stk[-1][0]<=arr[i]:
			stk.pop()
		if not stk:
			x.append(-1)
			stk.append([arr[i],i])
		else:
			x.append(stk[-1][1]+1)
			stk.append([arr[i],i])
stk.clear()
stk=[[arr[-1],len(arr)-1]]
y=[-1]
for i in reversed(range(len(arr)-1)):
	if stk[-1][0]>arr[i]:
		y.append(stk[-1][1]+1)
		stk.append([arr[i],i])
	else:
		while stk and stk[-1][0]<=arr[i]:
			stk.pop()
		if not stk:
			y.append(-1)
			stk.append([arr[i],i])
		else:
			y.append(stk[-1][1]+1)
			stk.append([arr[i],i])

i=0
j=len(y)-1
while i<len(x) and j>=0:
	print(x[i]+y[j],end=' ')
	i+=1
	j-=1, In this Programming Language: Python, Now tell me if this Code is compilable or not?