PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#CC0000003. Rời rạc hóa các giá trị (Coordinate Compression (Za-atsu))

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Rời rạc hóa các giá trị (Coordinate Compression (Za-atsu))

Coordinate Compression (Za-atsu)

Source: AtCoder Version: Phuoc Hung OJ Extended

Problem Statement

Replace large integer values with compact ranks while preserving comparisons. Replace each aia_i by the number of distinct values smaller than aia_i in the full sequence. Ranks start at 00 and equal elements receive equal ranks.

Input

The first line contains NN. Each of the next NN lines contains one integer aia_i.

Output

Print NN lines; line ii contains the zero-based rank of aia_i.

Subtasks

  • Subtask 1 (30 points): 1≤N≤1031\le N\le 10^3; 0≤ai≤1090\le a_i\le 10^9.
  • Subtask 2 (30 points): 1≤N≤1051\le N\le 10^5; 0≤ai≤1050\le a_i\le 10^5.
  • Subtask 3 (40 points): 1≤N≤1051\le N\le 10^5; 0≤ai≤1090\le a_i\le 10^9.

Examples

Input

6
50
10
50
30
10
70

Output

2
0
2
1
0
3

Explanation

The sorted distinct values are 10,30,50,7010,30,50,70, with ranks 0,1,2,30,1,2,3. Restore the original positions.