#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
long long int N, er[maxn], g[maxn], s[maxn], f[maxn], ans[maxn];
vector<pair<long long int, long long int> > v;
int find(int a) {
  if (g[a] == a) return a;
  return g[a] = find(g[a]);
}
void merge(int a, int b) {
  a = find(a);
  b = find(b);
  if (s[a] < s[b]) swap(a, b);
  s[a] += s[b];
  g[b] = a;
  return;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> N;
  for (int i = 1; i <= N; i++) {
    cin >> er[i];
    v.push_back(pair<long long int, long long int>(er[i], i));
  }
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  for (int i = 1; i <= N; i++) g[i] = i, s[i] = 1;
  for (int i = 0; i < v.size(); i++) {
    f[v[i].second] = 1;
    if (f[v[i].second + 1]) merge(v[i].second, v[i].second + 1);
    if (f[v[i].second - 1]) merge(v[i].second, v[i].second - 1);
    (ans[s[find(v[i].second)]]) =
        max((ans[s[find(v[i].second)]]), (v[i].first));
  }
  for (int i = N; i >= 1; i--) (ans[i]) = max((ans[i]), (ans[i + 1]));
  for (int i = 1; i <= N; i++) cout << ans[i] << " ";
  cout << '\n';
  return 0;
}
