1 TC Failed please tell me what is wrong in my code

public class Main {

 public static void main(String[] args) {
	Scanner scanner  = new Scanner(System.in);
	int N  = scanner.nextInt();
	int[] arr = new int[N];
	for (int i = 0; i < arr.length; i++) {
		arr[i] = scanner.nextInt();
	}
	Stack<Integer> stack = new Stack<Integer>();

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

}