#include <bits/stdc++.h>
using namespace std;
struct node {
  int num, width;
  node(){};
  node(int _num, int _width) : num(_num), width(_width) {}
};
stack<node> S;
int a[200005], ans[200005];
int main() {
  int n, i, j;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  a[n++] = 0;
  memset(ans, 0, sizeof(ans));
  for (i = 0; i < n; i++) {
    int len = 0;
    node k;
    while (!S.empty()) {
      k = S.top();
      if (k.num < a[i]) break;
      int ls = k.width + len;
      if (k.num > ans[ls]) {
        ans[ls] = k.num;
      }
      len += k.width;
      S.pop();
    }
    S.push(node(a[i], len + 1));
  }
  for (i = n - 1; i >= 1; i--) ans[i] = max(ans[i], ans[i + 1]);
  printf("%d", ans[1]);
  for (i = 2; i < n; i++) printf(" %d", ans[i]);
  printf("\n");
  return 0;
}
