Plz send me the corrected code

my code;-
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner scn = new Scanner(System.in);
int n = scn.nextInt();

int [] arr =new int [n];
for (int i=0;i<n;i++) {
	arr[i]=scn.nextInt();
}

Stack<Integer> stack=new Stack<>();

for (int i=0;i<arr.length;i++) {
	while (!stack.isEmpty() && arr[i]>stack.peek()) {
		int rv=stack.pop();
		
		System.out.print(arr[i]+" ");
	}
	
	stack.push(arr[i]);
}

while(!stack.isEmpty()) {
	stack.pop();
	System.out.print("-1"+" ");
}

}
}

@harsh.hj
refer to this link https://ide.codingblocks.com/s/206129
I have explained the approach along with the code

In case of any doubt feel free to ask :slightly_smiling_face:
If you got the answer then mark your doubt as resolved

maam this code is of c++ but i am doing it with java and i doesnt know about vectors

refer to this