#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int n, a[maxn], l[maxn], r[maxn], ans[maxn];
stack<int> s;
int main() {
  memset(a, 0, sizeof(a));
  memset(l, 0, sizeof(l));
  memset(r, 0, sizeof(r));
  memset(ans, 0, sizeof(ans));
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  s.push(0);
  for (int i = 1; i <= n; i++) {
    while (a[s.top()] >= a[i]) s.pop();
    l[i] = s.top();
    s.push(i);
  }
  while (s.top()) s.pop();
  s.push(n + 1);
  for (int i = n; i >= 1; i--) {
    while (a[s.top()] >= a[i]) s.pop();
    r[i] = s.top();
    int k = r[i] - l[i] - 1;
    ans[k] = max(ans[k], a[i]);
    s.push(i);
  }
  for (int i = n - 1; i >= 1; i--) ans[i] = max(ans[i], ans[i + 1]);
  for (int i = 1; i <= n; i++) {
    printf(i == n ? "%d\n" : "%d ", ans[i]);
  }
  return 0;
}
