#include <bits/stdc++.h>
using namespace std;
int dadsadasda;
const int INF = 0x3f3f3f3f;
const long long LLINF = 1e18;
const int MAXN = 3e5;
int n;
int a[MAXN];
int ans[MAXN];
priority_queue<pair<int, int> > pq;
int father[MAXN], siz[MAXN], cnt[MAXN];
void makeSet(int nn, int m) {
  for (int i = nn; i <= m; ++i) {
    father[i] = -1;
    siz[i] = 0;
    cnt[i] = 1;
  }
}
int find(int x) {
  if (father[x] == -1) return x;
  return father[x] = find(father[x]);
}
void unio(int x, int y) {
  if (siz[x] > siz[y]) {
    father[y] = x;
    cnt[x] += cnt[y];
  } else {
    father[x] = y;
    cnt[y] += cnt[x];
    if (siz[x] == siz[y]) siz[y]++;
  }
}
bool active[MAXN];
int main() {
  dadsadasda = scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    dadsadasda = scanf("%d", &a[i]);
    pq.push({a[i], i});
  }
  makeSet(0, n - 1);
  while (!pq.empty()) {
    auto p = pq.top();
    pq.pop();
    active[p.second] = true;
    if (p.second > 0 && find(p.second) != find(p.second - 1) &&
        active[p.second - 1])
      unio(find(p.second), find(p.second - 1));
    if (p.second < n - 1 && find(p.second) != find(p.second + 1) &&
        active[p.second + 1])
      unio(find(p.second), find(p.second + 1));
    int sz = cnt[find(p.second)];
    ans[sz] = max(ans[sz], p.first);
  }
  for (int i = n - 1; i >= 1; i--) {
    ans[i] = max(ans[i], ans[i + 1]);
  }
  for (int i = 1; i < n + 1; i++) {
    printf("%d ", ans[i]);
  }
  printf("\n");
  return 0;
}
