#include <bits/stdc++.h>
using namespace std;
const int N = 200000;
int n;
int a[N];
int st[20][N];
map<int, int> sz;
int ans[N + 1];
int q(int ii, int len) {
  int l = log2(len);
  return min(st[l][ii], st[l][ii + len - (1 << l)]);
}
int bsr(int ii, int lo, int hi) {
  if (lo == hi) {
    return lo;
  }
  int mid = (lo + hi) / 2 + 1;
  if (q(ii, mid) == a[ii])
    return bsr(ii, mid, hi);
  else
    bsr(ii, lo, mid - 1);
}
int bsl(int ii, int lo, int hi) {
  if (lo == hi) {
    return lo;
  }
  int mid = (lo + hi) / 2 + 1;
  if (q(ii - mid + 1, mid) == a[ii])
    return bsl(ii, mid, hi);
  else
    return bsl(ii, lo, mid - 1);
}
int getr(int ii) { return bsr(ii, 0, n - ii); }
int getl(int ii) { return bsl(ii, 0, ii + 1); }
int main() {
  memset(ans, -1, sizeof(ans));
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < n; ++i) {
    st[0][i] = a[i];
  }
  for (int i = 1; i < 20; ++i) {
    for (int j = 0; j < n; ++j) {
      if (j + (1 << (i - 1)) < n)
        st[i][j] = min(st[i - 1][j], st[i - 1][j + (1 << (i - 1))]);
      else
        st[i][j] = st[i - 1][j];
    }
  }
  for (int i = 0; i < n; ++i) {
    sz[a[i]] = max(sz[a[i]], getr(i) + getl(i) - 1);
  }
  for (auto i = sz.begin(); i != sz.end(); ++i) {
    ans[i->second] = max(i->first, ans[i->second]);
  }
  int cur = *min_element(a, a + n);
  vector<int> sol;
  for (int w = n; w >= 1; --w) {
    if (ans[w] < 0) ans[w] = cur;
    sol.push_back(max(ans[w], cur));
    cur = max(ans[w], cur);
  }
  reverse(sol.begin(), sol.end());
  for (int i = 0; i < sol.size(); ++i) {
    cout << sol[i] << " ";
  }
  return 0;
}
