#include <bits/stdc++.h>
using namespace std;
const int H = (1 << 19);
int T[2 * H], a[H], ans[H];
int mini(int i, int l, int r, int x, int y) {
  if (r < x || y < l) return 0;
  if (x <= l && r <= y) return T[i];
  int i1 = mini(i * 2, l, (l + r) / 2, x, y);
  int i2 = mini(i * 2 + 1, (l + r) / 2 + 1, r, x, y);
  if (a[i1] < a[i2])
    return i1;
  else
    return i2;
}
void f(int l, int r) {
  if (l > r) return;
  int n = r - l + 1;
  int i = mini(1, 1, H, l, r);
  ans[n] = max(ans[n], a[i]);
  f(l, i - 1);
  f(i + 1, r);
}
int main() {
  int i, n;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    T[H - 1 + i] = i;
    ans[i] = -1;
  }
  a[0] = 1000000000 + 1;
  for (i = H - 1; i > 0; i--)
    if (a[T[i * 2]] < a[T[i * 2 + 1]])
      T[i] = T[i * 2];
    else
      T[i] = T[i * 2 + 1];
  f(1, n);
  for (i = n - 1; i >= 1; i--) {
    ans[i] = max(ans[i], ans[i + 1]);
  }
  for (i = 1; i <= n; i++) printf("%d ", ans[i]);
  printf("\n");
}
