#include <bits/stdc++.h>
using namespace std;
const int N = 2 * 1e5 + 7;
long long sz[N], par[N], vis[N], ans[N];
pair<long long, long long> p[N];
int getpar(int u) {
  if (par[u] == u)
    return u;
  else
    return getpar(par[u]);
}
void mrg(int u, int v) {
  if (par[u] == par[v]) return;
  u = getpar(u);
  v = getpar(v);
  par[v] = par[u];
  sz[u] += sz[v];
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    par[i] = i;
    sz[i] = 1;
  }
  for (int i = 0; i < n; i++) {
    cin >> p[i].first;
    p[i].second = i;
  }
  sort(p, p + n, greater<pair<long long, long long> >());
  int siz = 1;
  for (int i = 0; i < n; i++) {
    int x = p[i].first;
    int index = p[i].second;
    vis[index] = 1;
    if (index > 0 && vis[index - 1]) mrg(index, index - 1);
    if (index < n - 1 && vis[index + 1]) mrg(index, index + 1);
    while (siz <= sz[index]) {
      ans[siz] = x;
      siz++;
    }
  }
  for (int i = 1; i <= n; i++) cout << ans[i] << " ";
  return 0;
}
