#include <bits/stdc++.h>
using namespace std;
FILE* in = stdin;
FILE* out = stdout;
const int MAX = 262144;
const int INF = 1000000001;
const int TREE = 524288;
int tree[TREE];
void update(int idx1, int idx2, int val) {
  idx1 += (TREE >> 1), idx2 += (TREE >> 1);
  tree[idx1] = max(tree[idx1], val);
  bool flag1 = !(idx1 & 1);
  idx1 >>= 1;
  tree[idx2] = max(tree[idx2], val);
  bool flag2 = (idx2 & 1);
  idx2 >>= 1;
  while (idx1 != idx2) {
    if (flag1) tree[(idx1 << 1) | 1] = max(tree[(idx1 << 1) | 1], val);
    if (flag2) tree[(idx2 << 1) | 0] = max(tree[(idx2 << 1) | 0], val);
    flag1 = !(idx1 & 1);
    idx1 >>= 1;
    flag2 = (idx2 & 1);
    idx2 >>= 1;
  }
}
int query(int idx) {
  idx += (TREE >> 1);
  int ret = tree[idx];
  while (idx) ret = max(ret, tree[idx]), idx >>= 1;
  return ret;
}
int n;
int a[MAX];
int main(void) {
  fscanf(in, "%d", &n);
  for (int i = 0; i < n; i++) fscanf(in, "%d", &a[i]);
  set<int> s;
  s.insert(-1);
  s.insert(n);
  vector<pair<int, int> > v;
  for (int i = 0; i < n; i++) v.push_back(make_pair(a[i], i));
  sort(v.begin(), v.end());
  for (int i = 0; i < TREE; i++) tree[i] = -INF;
  for (int i = 0; i < (int)v.size(); i++) {
    set<int>::iterator l = s.upper_bound(v[i].second);
    l--;
    set<int>::iterator r = s.upper_bound(v[i].second);
    int len = *r - *l - 1;
    s.insert(v[i].second);
    update(0, len, v[i].first);
  }
  for (int i = 1; i <= n; i++)
    fprintf(out, "%d%c", query(i), i == n ? '\n' : ' ');
  return 0;
}
