For this Question: Given an array A of size N, the task is to find the nearest greater element G[i] for every element of A[i] such that the element has index greater than i, If no such element exists, output -1.
More formally:
G[i] for an element A[i] = an element A[j] such that 
    j is minimum possible AND 
    j > i AND
    A[j] > A[i]Each test case consists of two lines. The first line contains an integer N denoting the size of the array. The Second line of each test case contains N space separated positive integers denoting the values/elements in the array A.

Constraints:
1 <= N <= 10^5
1 <= Ai <= 10^9For each test case, print the next greater element for each array element separated by space in order.Sample Input
4
1 3 2 4

Sample Output
3 4 4 -1

Sample Input
4
4 3 2 1

Sample Output
-1 -1 -1 -1, I have written this Solution Code: def rightlarg(arr):
    n = len(arr)
    A =[None]*n
    A[-1] = -1
    Indx = [-1]*n
    stack = []
    s = 1
    stack.append([arr[-1],n-1])
    for i in range(n-2,-1,-1):
        while s :
            if stack[0][0]>arr[i] :
                A[i] = stack[0][0]
                Indx[i] = stack[0][1]
                break
            else:
                stack.pop(0)
                s -= 1
        else:
            A[i] = -1
        stack.insert(0,[arr[i],i])
        s += 1
    for x in Indx:
	    #print("kjhx ",x," jhgk")
	    if x==-1:
		    print(x,end=" ")
	    else:
		    print(arr[x],end=" ")
n=int(input())
B=[int(x) for x in input().split()]
rightlarg(B), In this Programming Language: Python, Now tell me if this Code is compilable or not?