#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010 << 1;
stack<int> S;
int n;
int a[maxn];
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  int l[maxn], r[maxn];
  memset(l, 0, sizeof(l));
  memset(r, 0x3f, sizeof(r));
  while (!S.empty()) S.pop();
  for (int i = 1; i <= n; i++) {
    while (!S.empty() && a[S.top()] >= a[i]) S.pop();
    if (S.empty())
      l[i] = 0;
    else
      l[i] = S.top();
    S.push(i);
  }
  while (!S.empty()) S.pop();
  for (int i = n; i >= 1; i--) {
    while (!S.empty() && a[S.top()] >= a[i]) S.pop();
    if (S.empty())
      r[i] = n + 1;
    else
      r[i] = S.top();
    S.push(i);
  }
  int ans[maxn];
  memset(ans, 0, sizeof(ans));
  for (int i = 1; i <= n; i++) {
    int t = r[i] - l[i] - 1;
    ans[t] = max(ans[t], a[i]);
  }
  for (int i = n; i >= 2; i--) {
    ans[i - 1] = max(ans[i - 1], ans[i]);
  }
  for (int i = 1; i <= n; i++) cout << ans[i] << " ";
  cout << endl;
}
