#include <bits/stdc++.h>
using namespace std;
int n, ans;
int v[200009], T[4 * 200009];
pair<int, int> info[200009];
vector<int> st;
void upd(int a, int b, int san, int l, int r, int node) {
  if (a <= l && b >= r) {
    T[node] = max(san, T[node]);
    return;
  }
  if (a > r || b < l) return;
  upd(a, b, san, l, (l + r) / 2, node * 2);
  upd(a, b, san, (l + r) / 2 + 1, r, node * 2 + 1);
}
void tap(int a, int l, int r, int node) {
  ans = max(ans, T[node]);
  if (l == r) return;
  if (a <= (l + r) / 2)
    tap(a, l, (l + r) / 2, node * 2);
  else
    tap(a, (l + r) / 2 + 1, r, node * 2 + 1);
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> v[i];
    while (!st.empty() && v[i] < v[st.back()])
      info[st.back()].second = i, st.pop_back();
    if (st.empty())
      info[i].first = 0;
    else {
      if (v[st.back()] == v[i])
        info[i].first = info[st.back()].first;
      else
        info[i].first = st.back();
    }
    info[i].second = n + 1, st.push_back(i);
  }
  for (int i = 1; i <= n; i++)
    upd(1, info[i].second - (info[i].first + 1), v[i], 1, n, 1);
  for (int i = 1; i <= n; i++) ans = 0, tap(i, 1, n, 1), cout << ans << " ";
}
