#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using ii = pair<int, int>;
template <class A, class B>
ostream& operator<<(ostream& os, pair<A, B> p) {
  return os << p.first << " " << p.second;
}
template <class A, class B>
istream& operator>>(istream& is, pair<A, B>& p) {
  return is >> p.first >> p.second;
}
const int oo = 0x3f3f3f3f;
const ll OO = ll(oo) * oo;
const int N = 200005;
int P[N];
int S[N];
void Build() {
  for (int i = 0; i < N; i++) {
    P[i] = i;
    S[i] = 1;
  }
}
int Find(int i) {
  while (i != P[i]) i = P[i] = P[P[i]];
  return i;
}
void Union(int i, int j) {
  if ((i = Find(i)) == (j = Find(j))) return;
  if (S[i] > S[j]) swap(i, j);
  P[i] = j;
  S[j] += S[i];
}
int ans[N];
int a[N];
struct Edge {
  int i, w;
  Edge() {}
  Edge(int i, int w) : i(i), w(w) {}
  bool operator<(const Edge& e) const { return w > e.w; }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  Build();
  int n;
  cin >> n;
  vector<Edge> g(n - 1);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    ans[1] = max(a[i], ans[1]);
    if (i > 0) g[i - 1] = Edge(i, min(a[i], a[i - 1]));
  }
  sort((g).begin(), (g).end());
  for (const Edge& e : g) {
    Union(e.i, e.i - 1);
    int f = Find(e.i);
    ans[S[f]] = max(ans[S[f]], e.w);
  }
  for (int i = n - 1; i > 0; i--) {
    ans[i] = max(ans[i], ans[i + 1]);
  }
  for (int i = 0; i < n; i++) cout << ans[i + 1] << ' ';
  cout << '\n';
  return 0;
}
