cho.sh
Notes
Loading...

Running

Time limit

1s

Memory limit

256 MB

Problem

In a long-distance running race, every runner has already passed the turnaround point. Among the runners currently ahead of a runner, any runner with a higher usual ability cannot be overtaken during the remaining distance. Conversely, any runner with a lower usual ability can be overtaken.

Each runner's usual ability is given as a distinct integer, and a larger value means a better runner. Given the current order from front to back, determine the best rank each runner can achieve during the remaining distance. For a runner, this best rank is 1 plus the number of runners ahead of them whose usual ability is higher.

Input

The first line contains an integer N, the number of runners. N is between 3 and 500,000 inclusive.

Each of the next N lines contains one integer, the usual ability of a runner, listed in the current order from front to back. Each ability value is between 1 and 1,000,000,000 inclusive, and all ability values are distinct.

Output

Print N integers, one per line, in the same order as the input. The i-th printed integer must be the best rank that the i-th runner can achieve.