#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 50;
struct Q {
  int v;
  int l, r;
  Q() {}
  Q(int v1, int l1, int r1) : v(v1), l(l1), r(r1) {}
} qmi[maxn];
int a[maxn], ans[maxn];
void solve(int n) {
  int head = 1, tail = 0;
  for (int i = 1; i <= n + 1; i++) {
    int l = i, r = i;
    while (head <= tail && qmi[tail].v >= a[i]) {
      l = qmi[tail].l;
      qmi[tail].r = r - 1;
      int len = qmi[tail].r - qmi[tail].l + 1;
      ans[len] = max(ans[len], qmi[tail].v);
      tail--;
    }
    qmi[++tail] = Q(a[i], l, r);
  }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  a[n + 1] = 0;
  solve(n);
  for (int i = n; i >= 1; i--) {
    ans[i] = max(ans[i], ans[i + 1]);
  }
  for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
  printf("\n");
}
