#include <bits/stdc++.h>
using namespace std;
const int maxn = 200010;
int n;
int a[maxn], r[maxn];
int fa[maxn], c[maxn];
int res[maxn];
int cmp(int x, int y) { return a[x] > a[y]; }
int find(int x) {
  if (fa[x] == x) return x;
  return fa[x] = find(fa[x]);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) r[i] = i;
  sort(r + 1, r + n + 1, cmp);
  for (int i = 1; i <= n; i++) {
    fa[i] = i;
    c[i] = 1;
  }
  res[1] = a[r[1]];
  res[n] = a[r[n]];
  for (int i = 1; i <= n; i++) {
    int x = r[i];
    if (a[x - 1] >= a[x] && find(x - 1) != find(x)) {
      c[find(x - 1)] += c[find(x)];
      fa[find(x)] = fa[find(x - 1)];
      res[c[find(x - 1)]] = max(res[c[find(x - 1)]], a[x]);
    }
    if (a[x + 1] >= a[x] && find(x + 1) != find(x)) {
      c[find(x + 1)] += c[find(x)];
      fa[find(x)] = fa[find(x + 1)];
      res[c[find(x + 1)]] = max(res[c[find(x + 1)]], a[x]);
    }
  }
  for (int i = n; i >= 1; i--) res[i] = max(res[i], res[i + 1]);
  printf("%d", res[1]);
  for (int i = 2; i <= n; i++) printf(" %d", res[i]);
  printf("\n");
  return 0;
}
