#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0},  {1, 1},   {0, 1},  {-1, 1},
                         {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};
int par[200010], r[200010], lar[200010];
void init() {
  for (int i = 0; i < 200010; i++) {
    par[i] = i;
    r[i] = 0;
    lar[i] = 1;
  }
}
int find(int x) {
  if (par[x] == x) return x;
  return par[x] = find(par[x]);
}
bool same(int x, int y) { return find(x) == find(y); }
void unit(int x, int y) {
  if (same(x, y)) return;
  x = find(x);
  y = find(y);
  if (r[x] < r[y]) {
    par[x] = y;
    lar[y] += lar[x];
  } else {
    par[y] = x;
    lar[x] += lar[y];
    if (r[x] == r[y]) {
      r[x]++;
    }
  }
}
int main() {
  static int n;
  static int a[200010];
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  init();
  bool used[200010];
  for (int i = 0; i < 200010; i++) {
    used[i] = false;
  }
  vector<pair<int, int> > vec;
  for (int i = 1; i <= n; i++) {
    vec.push_back(pair<int, int>(a[i], i));
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  int ans[200010];
  int k = 1;
  for (int i = 0; i < vec.size(); i++) {
    pair<int, int> p = vec[i];
    used[p.second] = true;
    if (used[p.second - 1]) {
      unit(p.second, p.second - 1);
    }
    if (used[p.second + 1]) {
      unit(p.second, p.second + 1);
    }
    for (; k <= lar[find(p.second)]; k++) {
      ans[k] = p.first;
    }
  }
  for (int i = 1; i <= n; i++) {
    printf("%d ", ans[i]);
  }
  puts("");
}
