#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 200005;
int l[MAX_N], r[MAX_N];
int a[MAX_N];
int n;
int F[MAX_N];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) {
    l[i] = i;
    while (a[l[i] - 1] >= a[i]) l[i] = l[l[i] - 1];
  }
  for (int i = n; i >= 1; i--) {
    r[i] = i;
    while (a[r[i] + 1] >= a[i]) r[i] = r[r[i] + 1];
  }
  for (int i = 1; i <= n; i++)
    F[r[i] - l[i] + 1] = max(F[r[i] - l[i] + 1], a[i]);
  for (int i = n; i >= 1; i--) F[i] = max(F[i], F[i + 1]);
  for (int i = 1; i <= n; i++) printf("%d ", F[i]);
  return 0;
}
