Array Manipulation at Moloco (Easy)

For each element, count how many earlier elements in the array are smaller, and print those counts one per line.

Easy2ArrayBrute forceInterviewNo attempts yetTime limit2sMemory limit512 MB

Problem

At Moloco, managing and analyzing big data is an important part of the core business. A colleague raised a complicated question one day, and you have to help resolve it.

You are given an array AA of nn distinct integers. Build a new array SS of nn integers, where S[i]S[i] is the number of elements placed before A[i]A[i] that are smaller than A[i]A[i].

S[i]={j:1j<i, A[j]<A[i]}S[i] = |\{ j : 1 \le j < i,\ A[j] < A[i] \}|

Indices start at 1. For instance, if A=[10,5,12,1,11]A = [10, 5, 12, 1, 11], then S=[0,0,2,0,3]S = [0, 0, 2, 0, 3].

Input

The first line contains an integer nn (1n10001 \le n \le 1000).

Each of the next nn lines contains one element of the array. Line i+1i+1 holds A[i]A[i]. All elements are distinct and satisfy A[i]2×109|A[i]| \le 2 \times 10^9.

Output

Print nn lines. Line ii contains S[i]S[i].