Mike is the president of country What-The-Fatherland. There are *n* bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to *n* from left to right. *i*-th bear is exactly *a*<sub class="lower-index">*i*</sub> feet high. 

A group of bears is a non-empty contiguous segment of the line. The size of a group is the number of bears in that group. The strength of a group is the minimum height of the bear in that group.

Mike is a curious to know for each *x* such that 1 ≤ *x* ≤ *n* the maximum strength among all groups of size *x*.
The first line of input contains integer *n* (1 ≤ *n* ≤ 2 × 10<sup class="upper-index">5</sup>), the number of bears.

The second line contains *n* integers separated by space, *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub> (1 ≤ *a*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">9</sup>), heights of bears.
def processLog (n):
  log = [0] * (n+1)
  log[2] = [1]
  for i in range(2,n+1): log[i] = log[int(i/2)] + 1
  return log

def printTable(arr):
  for i in range(len(arr)):
    print(arr[i])

def buildTable(arr, LOG):
  spt=[]
  for k in range(LOG):
      spt.append([922337203685477]*(n))
  for i in range(n):
      spt[0][i] = arr[i]    
  for j in range(1,LOG):
      for i in range(n):
          if i+(1<<(j-1))<n:
              spt[j][i]=min(spt[j-1][i],spt[j-1][i+(1<<(j-1))])
  return spt

def query(l, r):
  passo = (log[r - l + 1])
  return min(spt[passo][l], spt[passo][(r -(1<<passo) +1)])


def busca(i):
  l, r = 0, i
  num = spt[0][i]
  left, right = i, i
  while(l <= r):
    mid  = int((r + l) / 2)
    if query(mid, i) == num:
      r = mid - 1
      left = mid
    else:
      l = mid + 1

  l = i
  r = n - 1
  while (l<=r):
    mid  = int((r + l) / 2)
    if query(i, mid) == num:
      l = mid + 1
      right = mid
    else: 
      r = mid -1

  return right - left + 1

def build_ans():
  ans = [0] * (n+1)
  for i in range(n):
    result = busca(i)
    ans[result] = max(ans[result], spt[0][i])
  for i in range(n-1, -1, -1):
    ans[i] = max(ans[i], ans[i+1])

  return ans[1:]
    

n = int(input())
arr=list(map(int,input().split()))
log = processLog(n+5)
if n>1:
    LOG=log[n-1] + 1
else:
    LOG=0
spt = buildTable(arr, LOG)
ans = build_ans()
out = ''
for i in ans:
  print (i, end = ' ', flush=True)