There are n walruses standing in a queue in an airport. They are numbered starting from the queue's tail: the 1-st walrus stands at the end of the queue and the n-th walrus stands at the beginning of the queue. The i-th walrus has the age equal to ai.

The i-th walrus becomes displeased if there's a younger walrus standing in front of him, that is, if exists such j (i < j), that ai > aj. The displeasure of the i-th walrus is equal to the number of walruses between him and the furthest walrus ahead of him, which is younger than the i-th one. That is, the further that young walrus stands from him, the stronger the displeasure is.

The airport manager asked you to count for each of n walruses in the queue his displeasure.

Input

The first line contains an integer n (2 ≤ n ≤ 105) — the number of walruses in the queue. The second line contains integers ai (1 ≤ ai ≤ 109).

Note that some walruses can have the same age but for the displeasure to emerge the walrus that is closer to the head of the queue needs to be strictly younger than the other one.

Output

Print n numbers: if the i-th walrus is pleased with everything, print "-1" (without the quotes). Otherwise, print the i-th walrus's displeasure: the number of other walruses that stand between him and the furthest from him younger walrus.

Examples

Input

6
10 8 5 3 50 45


Output

2 1 0 -1 0 -1 

Input

7
10 4 6 3 2 8 15


Output

4 2 1 0 -1 -1 -1 

Input

5
10 3 1 10 11


Output

1 0 -1 -1 -1

Difficulty: MEDIUM
Tags: Sorting

Data structures
Skill types: Sorting

Data structures

Starter code:

Solutions:
from bisect import bisect_left
n = int(input())
a = list(map(int, input().split()))
b = [0] * n
for i in range(n - 1, -1, -1):
	b[i] = bisect_left(a, a[i], i + 1, len(a)) - i - 2
	a[i] = min(a[i + 1], a[i]) if i != n - 1 else a[i]
print(*b)


from typing import TypeVar, Generic, Callable, List
import sys
from array import array

def input():
	return sys.stdin.buffer.readline().decode('utf-8')
T = TypeVar('T')

class SegmentTree(Generic[T]):
	__slots__ = ['size', 'tree', 'identity', 'op', 'update_op']

	def __init__(self, size: int, identity: T, op: Callable[[T, T], T], update_op: Callable[[T, T], T]) -> None:
		self.size = size
		self.tree = [identity] * (size * 2)
		self.identity = identity
		self.op = op
		self.update_op = update_op

	def build(self, a: List[T]) -> None:
		tree = self.tree
		tree[self.size:self.size + len(a)] = a
		for i in range(self.size - 1, 0, -1):
			tree[i] = self.op(tree[i << 1], tree[(i << 1) + 1])

	def find(self, left: int, right: int) -> T:
		left += self.size
		right += self.size
		(tree, result, op) = (self.tree, self.identity, self.op)
		while left < right:
			if left & 1:
				result = op(tree[left], result)
				left += 1
			if right & 1:
				result = op(tree[right - 1], result)
			(left, right) = (left >> 1, right >> 1)
		return result

	def update(self, i: int, value: T) -> None:
		(op, tree) = (self.op, self.tree)
		i = self.size + i
		tree[i] = self.update_op(tree[i], value)
		while i > 1:
			i >>= 1
			tree[i] = op(tree[i << 1], tree[(i << 1) + 1])
n = int(input())
a = tuple(map(int, input().split()))
comp_dict = {x: i for (i, x) in enumerate(sorted(a), start=1)}
segt = SegmentTree[int](n + 10, -1, max, max)
ans = [-1] * n
for (i, x) in zip(range(n - 1, -1, -1), reversed(a)):
	res = segt.find(0, comp_dict[x])
	if res != -1:
		ans[i] = res - i - 1
	segt.update(comp_dict[x], i)
print(*ans)


n = int(input())
a = [int(x) for x in input().split(' ')]
INF = 1 << 30
mn = [INF] * n
for i in range(n - 1, -1, -1):
	mn[i] = min(a[i], mn[i + 1] if i + 1 < n else INF)
for i in range(n):
	l = i
	r = n - 1
	while l < r:
		mid = r - (r - l) // 2
		if mn[mid] >= a[i]:
			r = mid - 1
		else:
			l = mid
	print(l - i - 1, end=' ')


from collections import *
from sys import stdin
from copy import deepcopy

def arr_enu():
	return [[n - i, int(x)] for (i, x) in enumerate(stdin.readline().split())]

def min_arr(a):
	arr = deque(sorted(deepcopy(a), key=lambda x: x[1]))
	tem = deepcopy(arr)
	arr.appendleft([float('inf'), 0])
	for i in range(1, n + 1):
		arr[i][0] = min(arr[i][0], arr[i - 1][0])
	arr.popleft()
	return {tem[i][0]: arr[i][0] for i in range(n)}
n = int(input())
a = arr_enu()
(mem, ans) = (min_arr(a), [])
for (i, j) in a:
	ans.append(str(i - mem[i] - 1))
print(' '.join(ans))