#include <bits/stdc++.h>
using namespace std;
const long long maxn = (long long)(2e5 + 111);
long long L[maxn], R[maxn];
long long a[maxn], n;
pair<pair<long long, long long>, pair<long long, long long> > d[maxn];
long long len = 1;
long long ans[maxn];
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  L[1] = 1;
  for (int i = 2; i <= n; ++i) {
    int j = i - 1;
    while (j >= 1 && a[j] >= a[i]) j = L[j] - 1;
    L[i] = j + 1;
  }
  R[n] = n;
  for (int i = n - 1; i >= 1; i--) {
    int j = i + 1;
    while (j <= n && a[j] >= a[i]) j = R[j] + 1;
    R[i] = j - 1;
  }
  for (int i = 1; i <= n; ++i)
    d[i] =
        make_pair(make_pair(-a[i], -(R[i] - L[i] + 1)), make_pair(L[i], R[i]));
  sort(d + 1, d + 1 + n);
  for (int i = 1; i <= n; ++i) {
    long long v = -d[i].first.first;
    long long sz = -d[i].first.second;
    long long l = d[i].second.first;
    long long r = d[i].second.second;
    while (sz >= len) {
      ans[len] = max(ans[len], v);
      len++;
    }
  }
  for (int i = 1; i <= n; ++i) cout << ans[i] << ' ';
  return 0;
}
