E. MiniC
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

In this problem, you need to write a program to solve a problem in a C-like language called MiniC.

You are given an implementation of an interpreter of MiniC, written in C++, in the contest materials section. You are also given a PDF file containing technical details about this language. You may explore freely using the provided source code.

Write a program in MiniC to solve the following problem:

  • You are given a permutation $$$p_0,p_1,p_2,\ldots,p_{n-1}$$$ of $$$\{0,1,2,\ldots,n-1\}$$$. Define $$$f(i)$$$ to be the smallest $$$j$$$ such that $$$j \gt i$$$ and $$$p_j \lt p_i$$$, or $$$n$$$ if such $$$j$$$ does not exist. Find $$$f(i)$$$ for all $$$0 \le i \lt n$$$. The first integer of the input contains an integer $$$n$$$ ($$$1 \le n \le 1000$$$). The next $$$n$$$ integers represent $$$p_0,p_1,\ldots,p_{n-1}$$$ ($$$0 \le p_i \lt n$$$). You need to output $$$n$$$ integers to standard output, where the $$$i$$$-th integer represents $$$f(i-1)$$$.

Your MiniC program can use at most $$$256$$$ megabytes of memory and should take at most $$$1$$$ second to execute. Note that if your MiniC program gets a Compile Error, Runtime Error, Time Limit Exceeded, or Memory Limit Exceeded, your submission will get the Wrong Answer verdict.

Output

Output the program you wrote. Your program size should not exceed $$$5000$$$ characters.

Example
Input
5
0 3 1 4 2
Output
5
2
5
4
5
Note

Note that the sample input is what your MiniC program will receive, and the sample output is what your MiniC program should output. Your submitted code, in whatever language, should print the source code of your MiniC program.