#C12412. Rank Elements

    ID: 41837 Type: Default 1000ms 256MiB

Rank Elements

Rank Elements

Given a list of integers, your task is to replace every element with its rank among the unique values in the list. The smallest unique element is assigned a rank of 1, the second smallest is assigned a rank of 2, and so on. If an element appears more than once, each occurrence is replaced by the same rank.

Formally, let the input list be \(L = [l_1, l_2, \dots, l_n]\) and let the sorted unique elements be \(U = [u_1, u_2, \dots, u_k]\) with \(u_1 < u_2 < \dots < u_k\). Then, for each element \(l_i\), its rank is defined as the index \(j\) such that \(l_i = u_j\) (i.e. \(r(l_i)=j\)).

inputFormat

The first line contains an integer \(n\) denoting the number of elements. The second line contains \(n\) space-separated integers.

outputFormat

Output the rank of each element in the same order as they appear in the input. The ranks should be printed as space-separated integers. If the list is empty, output nothing.

## sample
1
3
1

</p>