#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const double eps = 1e-9;
const long long int mod = 1e9 + 7;
const int inf = 1LL << 30;
const int MAXN = 2e5 + 5;
int arr[MAXN];
void cp() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i];
  vector<int> L(n, -1), R(n, n);
  stack<int> st;
  for (int i = 0; i < n; i++) {
    while (!st.empty() && arr[st.top()] >= arr[i]) st.pop();
    if (!st.empty()) L[i] = st.top();
    st.push(i);
  }
  while (!st.empty()) st.pop();
  for (int i = n - 1; i >= 0; i--) {
    while (!st.empty() && arr[st.top()] >= arr[i]) st.pop();
    if (!st.empty()) R[i] = st.top();
    st.push(i);
  }
  while (!st.empty()) st.pop();
  vector<int> suff(n + 1);
  for (int i = 0; i < n; i++) {
    int r = R[i] - 1;
    int l = L[i] + 1;
    int v = r - l + 1;
    suff[v] = max(suff[v], arr[i]);
  }
  for (int i = n - 1; i > 0; i--) suff[i] = max(suff[i], suff[i + 1]);
  for (int i = 1; i <= n; i++) cout << suff[i] << " ";
  cout << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int t;
  t = 1;
  while (t--) {
    cp();
  }
  return 0;
}
