#include <bits/stdc++.h>
using namespace std;
int n;
int f[201000][20];
int a[201000];
int t(int k) { return 1 << k; }
int ans[201000];
int b[201000];
int getmin(int l, int r) {
  int lg2 = b[r - l + 1];
  return min(f[l][lg2], f[r - t(lg2) + 1][lg2]);
}
int main() {
  memset(b, 0, sizeof(b));
  for (int i = 1; t(i) < 201000; i++) b[t(i)] = 1;
  for (int i = 1; i < 201000; i++) b[i] += b[i - 1];
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    f[i][0] = a[i];
  }
  int m = b[n];
  for (int j = 1; j <= m; j++)
    for (int i = 1; i <= n; i++)
      if (i + t(j) - 1 <= n) f[i][j] = min(f[i][j - 1], f[i + t(j - 1)][j - 1]);
  memset(ans, 0, sizeof(ans));
  for (int i = 1; i <= n; i++) {
    int idl, idr;
    int l = 1, r = i;
    while (l < r) {
      int mid = (l + r) >> 1;
      if (getmin(mid, r) < a[i])
        l = mid + 1;
      else
        r = mid;
    }
    idl = l;
    l = i;
    r = n;
    while (l < r) {
      int mid = (l + r + 1) >> 1;
      if (getmin(l, mid) < a[i])
        r = mid - 1;
      else
        l = mid;
    }
    idr = r;
    ans[idr - idl + 1] = max(ans[idr - idl + 1], a[i]);
  }
  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]);
    if (i < n)
      putchar(' ');
    else
      putchar('\n');
  }
  return 0;
}
