from collections import defaultdict #A,B=map(inr,input().split()) #a=list(map(int,input().split())) from bisect import bisect_left as bl from bisect import bisect_right as br from math import log from fractions import gcd import sys input=sys.stdin.readline N=int(input()) A=list(map(int,input().split())) n=1 while(n1:#最下段かのチェック lazy[2*k+1]=lazy[k]//2 lazy[2*k+2]=lazy[k]//2 lazy[k]=0#伝搬終了 def add(a,b,x,k,l,r): eval(k,l,r) if b<=l or r<=a: return if a<=l and r<=b: lazy[k]+=(r-l)*x eval(k,l,r) else: add(a,b,x,2*k+1,l,(l+r)//2) add(a,b,x,2*k+2,(l+r)//2,r) dat[k]=dat[2*k+1]+dat[2*k+2] dict1=defaultdict(int) dict2=defaultdict(int) for i in range(N): if not(dict1[A[i]]): dict1[A[i]]=i+1 if not(dict2[A[N-1-i]]): dict2[A[N-1-i]]=N-i key=list(dict1.keys()) key.sort() for i in key: s=dict1[i]-1 t=dict2[i]-1 add(s,t+1,i,0,0,n) for i in range(N): print(find(i,i+1,0,0,n),end=" ") print()