#include <bits/stdc++.h>
using namespace std;
const int MAX = 2e5 + 2;
const int MOD = 1e9 + 7;
int a[MAX], l[MAX], r[MAX], tree[4 * MAX];
pair<int, int> p[MAX];
stack<int> s;
void build(int node, int start, int end) {
  if (start == end)
    tree[node] = a[start];
  else {
    int mid = (start + end) / 2;
    build(2 * node + 1, start, mid);
    build(2 * node + 2, mid + 1, end);
    tree[node] = max(tree[2 * node + 1], tree[2 * node + 2]);
  }
}
int query(int node, int start, int end, int l, int r) {
  if (r < start or end < l) return 0;
  if (l <= start and end <= r) return tree[node];
  int mid = (start + end) / 2;
  int p1 = query(2 * node + 1, start, mid, l, r);
  int p2 = query(2 * node + 2, mid + 1, end, l, r);
  return max(p1, p2);
}
int main() {
  int n, m, i, j, t;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  for (i = 0; i < n; i++) {
    while (!s.empty() && a[s.top()] >= a[i]) s.pop();
    if (s.empty())
      l[i] = -1;
    else
      l[i] = s.top();
    s.push(i);
  }
  while (!s.empty()) s.pop();
  for (i = n - 1; i >= 0; i--) {
    while (!s.empty() && a[s.top()] >= a[i]) s.pop();
    if (s.empty())
      r[i] = n;
    else
      r[i] = s.top();
    s.push(i);
  }
  for (i = 0; i < n; i++) p[i] = make_pair(r[i] - l[i] - 1, a[i]);
  sort(p, p + n);
  for (i = 0; i < n; i++) a[i] = p[i].second;
  build(0, 0, n - 1);
  for (i = 1; i <= n; i++) {
    j = lower_bound(p, p + n, make_pair(i, -1)) - p;
    printf("%d ", query(0, 0, n - 1, j, n - 1));
  }
  printf("\n");
  return 0;
}
