Try:
import java.util.*;
import java.lang.*;
import java.io.*;
class GFG
{
public static void main (String[] args)
{
Scanner sc = new Scanner(System.in);
int t=sc.nextInt();
List<Integer> list = new ArrayList<Integer>();
while(t-- > 0)
{
list.add(sc.nextInt());
}
for (int i = 0; i < list.size() - 1; i++)
{
Integer current = list.get(i);
Integer next = list.get(i+1);
if (current > next)
{
System.out.print(current + " ");
}
else
System.out.print("-1 ");
}
System.out.println("-1 ");
}
}