import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
int N = Integer.parseInt(br.readLine());
Stack<int[]> stack = new Stack<>();
st = new StringTokenizer(br.readLine());
for (int i = 0; i < N; i++) {
int top = Integer.parseInt(st.nextToken());
while (!stack.isEmpty()) {
if (stack.peek()[1] >= top) {
System.out.print(stack.peek()[0] + " ");
break;
}
stack.pop();
}
if (stack.isEmpty()) {
System.out.print(0 + " ");
}
stack.push(new int[] {i + 1, top});
}
}
}