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

Solutions:
n = int(input())
A = [int(i) for i in input().split()]
suf = [[10 ** 10, -1] for i in range(n)]
from bisect import bisect_left
suf[-1][0] = A[-1]
suf[-1][1] = n - 1
for i in range(n - 2, -1, -1):
	if suf[i + 1][0] > A[i]:
		suf[i][0] = A[i]
		suf[i][1] = i
	else:
		suf[i][0] = suf[i + 1][0]
		suf[i][1] = suf[i + 1][1]
ans = []
vals = [i[0] for i in suf]
for i in range(n):
	idx = bisect_left(vals, A[i])
	ans.append(max(-1, idx - i - 2))
print(*ans)


n = int(input())
a = list(map(int, input().split()))
m = [0] * n
for i in range(n - 1, -1, -1):
	if i == n - 1:
		m[i] = a[i]
	else:
		m[i] = min(a[i], m[i + 1])
res = [0 for i in range(n)]
for i in range(n):
	left = i + 1
	right = n - 1
	ans = -1
	while left <= right:
		mid = left + (right - left) // 2
		if m[mid] < a[i]:
			ans = mid
			left = mid + 1
		else:
			right = mid - 1
	if ans != -1:
		res[i] = abs(ans - i - 1)
	else:
		res[i] = -1
print(*res)


n = int(input())
arr = [int(i) for i in input().split()]
order = []
index = [0] * n
for i in range(len(arr)):
	order.append([arr[i], i])
order.sort()
oder = [i[1] + 1 for i in order]
dif_max = -1
for i in range(len(oder)):
	if oder[i] > dif_max:
		index[oder[i] - 1] = -1
		dif_max = oder[i]
	else:
		ans = dif_max - oder[i] - 1
		index[oder[i] - 1] = ans
for i in range(len(index) - 1):
	print(index[i], end=' ')
print(index[-1])


class Solution:

	def bazinga(self, n, m):
		r = [-1] * n
		m = sorted(range(len(m)), key=lambda k: m[k])
		mx = 0
		for i in range(n):
			mx = max(mx, m[i])
			r[m[i]] = mx - m[i] - 1
		print(*r)
n = int(input().strip())
m = list(map(int, input().strip().split()))
S = Solution()
S.bazinga(n, m)


from bisect import *
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, n) - i - 2
	a[i] = min(a[i + 1], a[i]) if i != n - 1 else a[i]
print(*b)


n = int(input())
x = [int(q) for q in input().split()]
l = [0] * n

def search(i, l, h):
	pos = -1
	while h >= l:
		mid = (l + h) // 2
		if x[mid] < x[i]:
			pos = mid
			l = mid + 1
		else:
			h = mid - 1
	if pos != -1:
		return pos - i - 1
	else:
		return -1
for i in range(n - 1, -1, -1):
	l[i] = search(i, i + 1, n - 1)
	if i != n - 1:
		x[i] = min(x[i + 1], x[i])
print(' '.join(map(str, l)))


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from bisect import bisect_left
n = int(input())
arr = list(map(int, input().split()))
ans = [-1] * n
m = arr[-1]
for i in range(n - 1, -1, -1):
	m = min(arr[i], m)
	ans[i] = m
f = [-1] * n
for i in range(n - 1):
	if arr[i] == ans[i]:
		continue
	var = bisect_left(ans, arr[i]) - 1
	if ans[var] == arr[i]:
		pass
	else:
		f[i] = var - i - 1
print(*f)


def ans(n, inputted):
	inputted.sort()
	ans1 = [-1] * n
	maxi = 0
	for i in range(n):
		if inputted[i][1] <= maxi:
			ans1[inputted[i][1]] = maxi - inputted[i][1] - 1
		maxi = max(maxi, inputted[i][1])
	print(' '.join((str(x) for x in ans1)))
n = int(input())
p = []
k = []
p = [int(x) for x in input().split()]
for i in range(n):
	k.append((p[i], i))
ans(n, k)


n = int(input())
t = [(n - i, j) for (i, j) in enumerate(map(int, input().split()), 1)]
t = [a[0] for a in sorted(t, key=lambda a: a[1])]
(p, q) = ([0] * n, [-1] * n)
for i in range(n):
	p[t[i]] = i + 1
for (i, j) in enumerate(p, 1):
	if n < j:
		continue
	for k in range(j, n):
		q[t[k]] = t[k] - i
	n = j - 1
q.reverse()
print(' '.join(map(str, q)))


def sort_list(list1, list2):
	zipped_pairs = zip(list2, list1)
	z = [x for (_, x) in sorted(zipped_pairs)]
	return z
n = int(input())
l = list(map(int, input().split()))
a = [i for i in range(n)]
a = sort_list(a, l)
l.sort()
ma = -1
ans = [-1] * n
for i in range(n):
	if a[i] > ma:
		ans[a[i]] = -1
	else:
		ans[a[i]] = ma - a[i] - 1
	ma = max(ma, a[i])
print(*ans, sep=' ')


from sys import stdin
input = stdin.readline
n = int(input())
a = [int(x) for x in input().split()]
b = []
min_ = float('inf')
for i in range(n - 1, -1, -1):
	if a[i] < min_:
		min_ = a[i]
		b.append((a[i], i))
b.reverse()
ans = []
for i in range(n):
	l = 0
	r = len(b)
	best_idx = float('-inf')
	while l < r:
		m = l + (r - l) // 2
		if a[i] > b[m][0]:
			if i < b[m][1]:
				best_idx = max(best_idx, b[m][1])
			l = m + 1
		else:
			r = m
	if best_idx == float('-inf'):
		ans.append(-1)
	else:
		ans.append(best_idx - i - 1)
print(*ans)


n = int(input())
arr = list(map(int, input().split()))
ans = [0] * n

def b_S(i, l, h):
	pos = -1
	ans1 = 100000
	while l <= h:
		mid = (l + h) // 2
		if arr[mid] < arr[i]:
			pos = mid
			ans1 = arr[mid]
			l = mid + 1
		else:
			h = mid - 1
	if pos != -1:
		return pos - i - 1
	return -1
for i in range(n - 1, -1, -1):
	ans[i] = b_S(i, i + 1, n - 1)
	if i != n - 1:
		arr[i] = min(arr[i + 1], arr[i])
print(*ans)


def disp(walline):
	walline = sorted(walline)
	highest_ind = -1
	displeasure_arr = [-1] * len(walline)
	for wal in walline:
		if wal[1] < highest_ind:
			displeasure_arr[wal[1]] = highest_ind - wal[1] - 1
		highest_ind = max(highest_ind, wal[1])
	return displeasure_arr
n = int(input())
walrus_arr = list(map(int, input().split()))
walrus_arr = [(age, ind) for (ind, age) in enumerate(walrus_arr)]
print(*disp(walrus_arr))


n = int(input())
arr = [int(X) for X in input().split()]
temp = []
for i in range(n):
	temp.append([arr[i], i])
temp.sort()
maxi = 0
ans = [0 for i in range(n)]
for i in range(n):
	maxi = max(maxi, temp[i][1])
	ans[temp[i][1]] = maxi - temp[i][1] - 1
for i in ans:
	print(i, end=' ')


n = int(input())
l = [int(x) for x in input().split()]
m = [[l[i], i, -1] for i in range(0, n)]
m.sort()
k = 0
for i in range(1, n):
	if m[k][1] - m[i][1] > 0:
		m[i][2] = m[k][1] - m[i][1] - 1
	else:
		k = i
		m[k][2] = -1
m.sort(key=lambda x: x[1])
for i in range(0, n):
	print(m[i][2], end=' ')


def binsearch(a, x):
	(l, r) = (-1, len(a))
	while r - l > 1:
		m = l + (r - l) // 2
		if a[m][0] < x:
			r = m
		else:
			l = m
	return r

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	stack = [(a[n - 1], n - 1)]
	ans = [-1 for i in range(n)]
	for i in range(n - 2, -1, -1):
		pos = binsearch(stack, a[i])
		if pos == len(stack):
			stack.append((a[i], i))
		else:
			ans[i] = stack[pos][1] - i - 1
	return ans
for x in solve():
	print(x, end=' ')


n = int(input())
a = [int(i) for i in input().split()]
ar1 = [0 for i in range(n)]
ar1[n - 1] = n - 1
for i in range(n - 2, -1, -1):
	if a[i] <= a[ar1[i + 1]]:
		ar1[i] = i
	else:
		ar1[i] = ar1[i + 1]
arr = [0] * n
for i in range(0, n):
	mid = 0
	ans = -1
	low = i + 1
	high = n - 1
	x = i
	while low <= high:
		mid = (high + low) // 2
		if a[ar1[mid]] < a[x]:
			ans = ar1[mid]
			low = mid + 1
		else:
			high = mid - 1
	if ans == -1:
		arr[i] = -1
	else:
		arr[i] = ans - i - 1
print(*arr)


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))


n = int(input())
a = list(map(int, input().split()))
b = [0] * n
c = []
c1 = 0
for i in range(n - 1, -1, -1):
	if c == [] or a[i] < c[c1 - 1][0]:
		c.append([a[i], i])
		c1 += 1
	if i == n - 1 or (a[i] <= a[i + 1] and b[i + 1] == -1):
		b[i] = -1
	elif a[i] == a[i + 1]:
		b[i] = b[i + 1] + 1
	elif a[i] == c[c1 - 1][0]:
		b[i] = -1
	else:
		m = round(c1 / 2)
		m = min(c1 - 1, max(0, m))
		k = m
		while round(k) > 0:
			if c[m][0] > a[i]:
				m += round(k / 2)
				m = min(c1 - 1, max(0, m))
			else:
				m -= round(k / 2)
				m = min(c1 - 1, max(0, m))
			k /= 2
		while m < c1 - 1 and c[m][0] >= a[i]:
			m += 1
		while m > 0 and c[m - 1][0] < a[i]:
			m -= 1
		b[i] = c[m][1] - i - 1
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)


import itertools
from bisect import bisect_left

def main():
	n = int(input())
	a = list(map(int, input().split()))
	b = sorted(enumerate(reversed(a)), key=lambda y: y[1])
	(indices, values) = zip(*b)
	(indices, values) = (list(itertools.accumulate(indices, min)), list(values))
	for (pos, x) in zip(range(n - 1, -1, -1), a):
		index = bisect_left(values, x)
		if index == n or values[index] >= x:
			index -= 1
		print(-1 if index < 0 else max(-1, pos - indices[index] - 1), end=' ')
main()


n = int(input())
l = []
for (i, j) in enumerate(map(int, input().split())):
	l.append((j, i))
l = sorted(l)
mx = -1
ans = [0] * n
for (val, i) in l:
	mx = max(mx, i)
	ans[i] = mx - i - 1
print(*ans)


n = int(input())
a = list(map(int, input().split(' ')))
ans = [0] * n

def bsearch(i, l, h):
	pos = -1
	while h >= l:
		mid = (l + h) // 2
		if a[mid] < a[i]:
			pos = mid
			l = mid + 1
		else:
			h = mid - 1
	if pos != -1:
		return pos - i - 1
	else:
		return -1
for i in range(n - 1, -1, -1):
	ans[i] = bsearch(i, i + 1, n - 1)
	if i != n - 1:
		a[i] = min(a[i + 1], a[i])
print(' '.join(map(str, ans)))


from sys import stdin, stdout
from math import log2
nmbr = lambda : int(stdin.readline())
lst = lambda : list(map(int, stdin.readline().split()))
PI = float('inf')

def RMQ(low, high):
	l = high - low + 1
	k = int(log2(l))
	return min(a[sp[low][k]], a[sp[low + l - (1 << k)][k]])
for _ in range(1):
	n = nmbr()
	a = lst()
	col = int(log2(n)) + 1
	sp = [[0 for _ in range(col + 1)] for _ in range(n)]
	for i in range(n):
		sp[i][0] = i
	j = 1
	while 1 << j <= n:
		i = 0
		while i + (1 << j) - 1 < n:
			if a[sp[i][j - 1]] < a[sp[i + (1 << j - 1)][j - 1]]:
				sp[i][j] = sp[i][j - 1]
			else:
				sp[i][j] = sp[i + (1 << j - 1)][j - 1]
			i += 1
		j += 1
	for i in range(n):
		(l, r) = (i + 1, n - 1)
		while l <= r:
			mid = l + r >> 1
			if RMQ(mid, n - 1) < a[i]:
				l = mid + 1
			else:
				r = mid - 1
		stdout.write(str(r - i - 1) + ' ')


from collections import defaultdict
mod = 10 ** 9 + 7
for _ in range(1):
	n = int(input())
	l = list(map(int, input().split()))
	l = l[::-1]
	a = [l[0]]
	pos = [0]
	ans = []
	for i in range(1, n):
		if a[-1] > l[i]:
			pos.append(i)
		else:
			pos.append(pos[-1])
		a.append(min(a[-1], l[i]))
	for i in range(n):
		j = pos[i]
		x = i
		while j >= 0 and a[j] < l[i]:
			x = j
			if j == 0:
				break
			j = pos[j - 1]
		if l[i] == a[x]:
			ans.append(-1)
		else:
			ans.append(i - pos[x] - 1)
	print(*ans[::-1])


import bisect
n = int(input())
arr = list(map(int, input().split()))
small = [-1] * n
small[n - 1] = arr[n - 1]
for i in range(n - 2, -1, -1):
	if arr[i] < small[i + 1]:
		small[i] = arr[i]
	else:
		small[i] = small[i + 1]
for i in range(n):
	ans = bisect.bisect_left(small, arr[i]) - i - 2
	if ans < 0:
		ans = -1
	print(ans, end=' ')


n = int(input())
import bisect
arr = list(map(int, input().strip().split()))[:n]
mins = [0] * n
mins[n - 1] = arr[-1]
for i in range(n - 2, -1, -1):
	mins[i] = min(mins[i + 1], arr[i])
ans = []
for i in range(n - 1):
	if arr[i] <= mins[i + 1]:
		ans.append(-1)
	else:
		ind = bisect.bisect_right(mins, arr[i] - 1)
		ans.append(ind - i - 2)
ans.append(-1)
for num in ans:
	print(num, end=' ')


b = [0] * int(input())
m = 0
for (e, i) in sorted(((e, i) for (i, e) in enumerate(map(int, input().split())))):
	m = max(m, i)
	b[i] = m - i - 1
print(*b)


n = int(input())
from bisect import bisect_left as br
a = [int(x) for x in input().split()]
mn = [10 ** 10 for i in range(n)]
mn[-1] = a[-1]
for i in range(n - 2, -1, -1):
	mn[i] = min(mn[i + 1], a[i])
ans = [0] * n
for i in range(n):
	pos = br(mn, a[i])
	if a[pos - 1] < a[i]:
		ans[i] = max(-1, pos - 1 - i - 1)
	else:
		ans[i] = -1
print(*ans)


from collections import deque

def bs(l, k):
	lo = 0
	ans = -1
	hi = len(l) - 1
	while lo <= hi:
		mi = lo + hi >> 1
		if l[mi] < k:
			ans = l[mi]
			lo = mi + 1
		else:
			hi = mi - 1
	return ans
for _ in range(1):
	n = int(input())
	ind = {}
	suff = [int(i) for i in input().split()]
	search = deque()
	ans = [0] * n
	for i in range(n - 1, -1, -1):
		if not search:
			search.append(suff[i])
			ind[suff[i]] = i
		elif suff[i] < search[0]:
			search.appendleft(suff[i])
			ind[suff[i]] = i
		z = bs(search, suff[i])
		if z == -1:
			ans[i] = -1
		else:
			ans[i] = ind[z] - i - 1
	print(' '.join((str(i) for i in ans)))


import sys
import math as m

def fi():
	return sys.stdin.readline()
n = int(fi())
l = list(map(int, fi().split()))
ans = [0] * n
mi = [0] * n
ans[n - 1] = -1
mi[n - 1] = l[n - 1]
for i in range(n - 2, -1, -1):
	mi[i] = min(l[i], mi[i + 1])
for i in range(n - 2, -1, -1):
	a = -1
	le = i + 1
	r = n - 1
	while le <= r:
		mid = (le + r) // 2
		if mi[mid] < l[i]:
			a = mid
			le = mid + 1
		else:
			r = mid - 1
	if a == -1:
		ans[i] = a
	else:
		ans[i] = a - i - 1
print(*ans)


from math import ceil, sqrt
from collections import defaultdict

def solve():
	n = int(input())
	l = list(map(int, input().split()))
	hash = defaultdict(list)
	for i in range(n):
		hash[l[i]].append(i + 1)
	l.sort()
	ans = [0] * (n + 1)
	maxi = 0
	for i in range(n):
		if l[i] == l[0]:
			z = hash[l[i]].pop(0)
			maxi = max(z, maxi)
			ans[z] = -1
		else:
			z = hash[l[i]].pop(0)
			maxi = max(z, maxi)
			ans[z] = maxi - z - 1
	print(*ans[1:])
solve()


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=' ')


def BinarySearch(lst, dp, start, end, Value):
	left_minimum = start
	while start <= end:
		mid = (start + end) // 2
		if lst[dp[mid]] < Value:
			start = mid + 1
			left_minimum = mid
		else:
			end = mid - 1
	return left_minimum
n = int(input())
lst = list(map(int, input().split()))
dp = [0 for i in range(n)]
Min = lst[n - 1]
Index = n - 1
dp[n - 1] = n - 1
for j in range(n - 2, -1, -1):
	if lst[j] < Min:
		Min = lst[j]
		Index = j
	dp[j] = Index
for j in range(n):
	Index = BinarySearch(lst, dp, j, n - 1, lst[j])
	if Index > j:
		print(Index - j - 1, end=' ')
	else:
		print(-1, end=' ')
print()


import sys
read = lambda : sys.stdin.readline().strip()
readi = lambda : map(int, read().split())
n = int(read())
nums = list(readi())
arr = [(num, i) for (i, num) in enumerate(nums)]
arr.sort(key=lambda x: x[0])
prefixMax = [-1] * (n + 1)
for (i, (num, j)) in enumerate(arr):
	prefixMax[i + 1] = max(prefixMax[i], j)
ans = [-1] * n
for i in range(n):
	ans[arr[i][1]] = prefixMax[i + 1] - arr[i][1] - 1
print(' '.join(map(str, ans)))


from sys import stdin, stdout
nmbr = lambda : int(stdin.readline())
lst = lambda : list(map(int, stdin.readline().split()))
for _ in range(1):
	n = nmbr()
	a = lst()
	suf = [0] * n
	suf[n - 1] = a[n - 1]
	for i in range(n - 2, -1, -1):
		suf[i] = min(a[i], suf[i + 1])
	for i in range(n):
		(l, r) = (i + 1, n - 1)
		while l <= r:
			mid = l + r >> 1
			if suf[mid] < a[i]:
				l = mid + 1
			else:
				r = mid - 1
		stdout.write(str(r - i - 1) + ' ')


n = int(input())
x = list(map(int, input().split()))
arr = []
for i in range(n):
	arr.append((x[i], i))
arr.sort(key=lambda arr: arr[0])
ans = [-1] * n
maxx = 0
for i in range(n):
	maxx = max(maxx, arr[i][1])
	ans[arr[i][1]] = maxx - arr[i][1] - 1
for i in ans:
	print(i, end=' ')


def disp(wal1):
	wal1 = sorted(wal1)
	highest_ind = -1
	ret_arr = [-1] * len(wal1)
	for wal in wal1:
		if wal[1] < highest_ind:
			ret_arr[wal[1]] = highest_ind - wal[1] - 1
		highest_ind = max(highest_ind, wal[1])
	return ret_arr
n = int(input())
walrus_arr = list(map(int, input().split()))
walrus_arr = [(age, ind) for (ind, age) in enumerate(walrus_arr)]
for wal in disp(walrus_arr):
	print(wal, end=' ')


def f(u, low, high):
	poss = -1
	while high >= low:
		mid = (low + high) // 2
		if a[mid] < a[u]:
			poss = mid
			low = mid + 1
		else:
			high = mid - 1
	return poss - u - 1 if poss != -1 else -1
n = int(input())
a = list(map(int, input().split()))
ans = [0] * n
for i in range(n - 1, -1, -1):
	ans[i] = f(i, i + 1, n - 1)
	if i != n - 1:
		a[i] = min(a[i + 1], a[i])
print(' '.join(map(str, ans)))


import bisect
n = int(input())
arr = list(map(int, input().split()))
arr1 = []
for i in range(n):
	arr1.append([arr[i], i])
arr1 = sorted(arr1, key=lambda a: a[0])
q = [-1] * n
k = 0
for a in arr1:
	if k < a[1]:
		k = a[1]
	else:
		q[a[1]] = k - a[1] - 1
print(*q)


from sys import stdin as si

class Solution:

	def bazinga(self, n, m):
		r = [-1] * n
		m = sorted(range(len(m)), key=lambda k: m[k])
		mx = 0
		for i in range(n):
			mx = max(mx, m[i])
			r[m[i]] = mx - m[i] - 1
		print(*r)
n = int(si.readline().strip())
m = list(map(int, si.readline().strip().split()))
S = Solution()
S.bazinga(n, m)


(k, q) = (0, ['-1'] * int(input()))
for (i, a) in sorted(enumerate(map(int, input().split())), key=lambda a: a[1]):
	if k < i:
		k = i
	else:
		q[i] = str(k - i - 1)
print(' '.join(q))


import os
import sys
from io import BytesIO, IOBase
import heapq as h
import bisect
from types import GeneratorType
BUFSIZE = 8192

class SortedList:

	def __init__(self, iterable=[], _load=200):
		values = sorted(iterable)
		self._len = _len = len(values)
		self._load = _load
		self._lists = _lists = [values[i:i + _load] for i in range(0, _len, _load)]
		self._list_lens = [len(_list) for _list in _lists]
		self._mins = [_list[0] for _list in _lists]
		self._fen_tree = []
		self._rebuild = True

	def _fen_build(self):
		self._fen_tree[:] = self._list_lens
		_fen_tree = self._fen_tree
		for i in range(len(_fen_tree)):
			if i | i + 1 < len(_fen_tree):
				_fen_tree[i | i + 1] += _fen_tree[i]
		self._rebuild = False

	def _fen_update(self, index, value):
		if not self._rebuild:
			_fen_tree = self._fen_tree
			while index < len(_fen_tree):
				_fen_tree[index] += value
				index |= index + 1

	def _fen_query(self, end):
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		x = 0
		while end:
			x += _fen_tree[end - 1]
			end &= end - 1
		return x

	def _fen_findkth(self, k):
		_list_lens = self._list_lens
		if k < _list_lens[0]:
			return (0, k)
		if k >= self._len - _list_lens[-1]:
			return (len(_list_lens) - 1, k + _list_lens[-1] - self._len)
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		idx = -1
		for d in reversed(range(len(_fen_tree).bit_length())):
			right_idx = idx + (1 << d)
			if right_idx < len(_fen_tree) and k >= _fen_tree[right_idx]:
				idx = right_idx
				k -= _fen_tree[idx]
		return (idx + 1, k)

	def _delete(self, pos, idx):
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len -= 1
		self._fen_update(pos, -1)
		del _lists[pos][idx]
		_list_lens[pos] -= 1
		if _list_lens[pos]:
			_mins[pos] = _lists[pos][0]
		else:
			del _lists[pos]
			del _list_lens[pos]
			del _mins[pos]
			self._rebuild = True

	def _loc_left(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(lo, pos) = (-1, len(_lists) - 1)
		while lo + 1 < pos:
			mi = lo + pos >> 1
			if value <= _mins[mi]:
				pos = mi
			else:
				lo = mi
		if pos and value <= _lists[pos - 1][-1]:
			pos -= 1
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value <= _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def _loc_right(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(pos, hi) = (0, len(_lists))
		while pos + 1 < hi:
			mi = pos + hi >> 1
			if value < _mins[mi]:
				hi = mi
			else:
				pos = mi
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value < _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def add(self, value):
		_load = self._load
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len += 1
		if _lists:
			(pos, idx) = self._loc_right(value)
			self._fen_update(pos, 1)
			_list = _lists[pos]
			_list.insert(idx, value)
			_list_lens[pos] += 1
			_mins[pos] = _list[0]
			if _load + _load < len(_list):
				_lists.insert(pos + 1, _list[_load:])
				_list_lens.insert(pos + 1, len(_list) - _load)
				_mins.insert(pos + 1, _list[_load])
				_list_lens[pos] = _load
				del _list[_load:]
				self._rebuild = True
		else:
			_lists.append([value])
			_mins.append(value)
			_list_lens.append(1)
			self._rebuild = True

	def discard(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_right(value)
			if idx and _lists[pos][idx - 1] == value:
				self._delete(pos, idx - 1)

	def remove(self, value):
		_len = self._len
		self.discard(value)
		if _len == self._len:
			raise ValueError('{0!r} not in list'.format(value))

	def pop(self, index=-1):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		value = self._lists[pos][idx]
		self._delete(pos, idx)
		return value

	def bisect_left(self, value):
		(pos, idx) = self._loc_left(value)
		return self._fen_query(pos) + idx

	def bisect_right(self, value):
		(pos, idx) = self._loc_right(value)
		return self._fen_query(pos) + idx

	def count(self, value):
		return self.bisect_right(value) - self.bisect_left(value)

	def __len__(self):
		return self._len

	def __getitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		return self._lists[pos][idx]

	def __delitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		self._delete(pos, idx)

	def __contains__(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_left(value)
			return idx < len(_lists[pos]) and _lists[pos][idx] == value
		return False

	def __iter__(self):
		return (value for _list in self._lists for value in _list)

	def __reversed__(self):
		return (value for _list in reversed(self._lists) for value in reversed(_list))

	def __repr__(self):
		return 'SortedList({0})'.format(list(self))

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import collections as col
import math, string

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())
MOD = 10 ** 9 + 7
mod = 10 ** 9 + 7
t = 1
p = 10 ** 9 + 7

def ncr_util():
	inv[0] = inv[1] = 1
	fact[0] = fact[1] = 1
	for i in range(2, 300001):
		inv[i] = inv[i % p] * (p - p // i) % p
	for i in range(1, 300001):
		inv[i] = inv[i - 1] * inv[i] % p
		fact[i] = fact[i - 1] * i % p

def solve():
	l1 = []
	x = l[len(l) - 1]
	l1.append(x)
	d = {}
	d[x] = len(l) - 1
	for i in range(len(l) - 1, -1, -1):
		if x > l[i]:
			x = l[i]
			d[x] = i
			l1.append(x)
		else:
			l1.append(l1[-1])
	ans = []
	l1.reverse()
	for i in range(len(l)):
		if l1[i] < l[i]:
			pos = bisect.bisect_left(l1, l[i])
			ans.append(d[l1[pos - 1]] - i - 1)
		else:
			ans.append(-1)
	return ans
for _ in range(t):
	n = int(input())
	l = list(map(float, input().split()))
	print(*solve())


from bisect import bisect_left as bl
num = int(input())
walrusQ = [int(i) for i in input().split()]
dspl = [10 ** 10 for i in range(num)]
dspl[-1] = walrusQ[-1]
for i in range(num - 2, -1, -1):
	dspl[i] = min(dspl[i + 1], walrusQ[i])
result = [0] * num
for i in range(num):
	pos = bl(dspl, walrusQ[i])
	if walrusQ[pos - 1] < walrusQ[i]:
		result[i] = max(-1, pos - 1 - i - 1)
	else:
		result[i] = -1
print(*result)


from math import gcd
input = __import__('sys').stdin.readline
n = int(input())
lis = list(map(int, input().split()))
ans = [0] * n
pre = [1 << 30] * n
for i in range(n - 1, -1, -1):
	pre[i] = min(lis[i], pre[i + 1] if i + 1 < n else 1 << 30)
for i in range(n):
	l = i
	r = n - 1
	while l <= r:
		mid = l + (r - l) // 2
		a = pre[mid]
		if a < lis[i]:
			l = mid + 1
		else:
			r = mid - 1
	if r < i:
		ans[i] = -1
	else:
		ans[i] = r - i - 1
print(*ans)


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = int(input())
l = [int(x) for x in input().split()]
m = [[l[i], i, -1] for i in range(0, n)]
m.sort()
k = 0
for i in range(1, n):
	if m[k][1] - m[i][1] > 0:
		m[i][2] = m[k][1] - m[i][1] - 1
	else:
		k = i
		m[k][2] = -1
m.sort(key=lambda x: x[1])
for i in range(0, n):
	print(m[i][2], end=' ')


n = int(input())
A = list(map(int, input().split()))
B = [0] * len(A)
C = [[0] * 3 for i in range(len(A))]
B[-1] = -1
C[-1][0] = A[-1]
C[-1][1] = len(A) - 1
C[-1][2] = len(A)
for i in range(len(A) - 2, -1, -1):
	if A[i] < C[i + 1][0]:
		B[i] = -1
		C[i][0] = A[i]
		C[i][1] = i
		C[i][2] = C[i + 1][1]
	elif A[i] == C[i + 1][0]:
		B[i] = -1
		C[i][0] = A[i]
		C[i][1] = C[i + 1][1]
		C[i][2] = C[i + 1][2]
	else:
		C[i][0] = C[i + 1][0]
		C[i][1] = C[i + 1][1]
		C[i][2] = C[i + 1][2]
		k = 0
		m = i
		while m + 1 < len(A) and A[i] > C[C[m + 1][1]][0]:
			k += C[m + 1][1] - m
			m = C[m + 1][1]
		k -= 1
		B[i] = k
for i in range(len(B)):
	print(B[i], end=' ')


INF = int(1000000000.0 + 7)
n = int(input())
a = list(map(int, input().split()))
suff = [INF] * (n + 1)
for i in range(n - 1, -1, -1):
	suff[i] = min(suff[i + 1], a[i])
ans = [0] * n
for i in range(n):
	L = i + 1
	R = n
	if suff[i + 1] >= a[i]:
		print(-1, end=' ')
		continue
	while R - L > 1:
		M = (R + L) // 2
		if suff[M] >= a[i]:
			R = M
		else:
			L = M
	print(R - i - 2, end=' ')


from bisect import bisect_left, bisect_right
import os
import sys
from io import BytesIO, IOBase
from collections import Counter, defaultdict
from collections import deque
from functools import cmp_to_key
import math
import heapq
import re

def sin():
	return input()

def ain():
	return list(map(int, sin().split()))

def sain():
	return input().split()

def iin():
	return int(sin())
MAX = float('inf')
MIN = float('-inf')
MOD = 1000000007

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	s = set()
	for p in range(2, n + 1):
		if prime[p]:
			s.add(p)
	return s

def readTree(n, m):
	adj = [deque([]) for _ in range(n + 1)]
	for _ in range(m):
		(u, v) = ain()
		adj[u].append(v)
		adj[v].append(u)
	return adj

def main():
	n = iin()
	d = deque([])
	l = ain()
	for i in range(n):
		d.append([l[i], i])
	k = sorted(d)
	maxi = MIN
	ans = [0] * n
	for i in range(n):
		maxi = max(maxi, k[i][1])
		ans[k[i][1]] = maxi - k[i][1] - 1
	print(*ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
if os.getcwd() == 'D:\\code':
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	input = lambda : sys.stdin.readline().rstrip('\r\n')
main()