#include <bits/stdc++.h>
using namespace std;
int sta[200005], num[200005], l[200005], r[200005], maxed[200005];
int main() {
  int n, ptr = 1, track;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> num[i];
  sta[1] = 1;
  l[1] = 0, r[1] = n + 1;
  for (int i = 2; i <= n; i++) {
    while (ptr >= 1 && num[i] <= num[sta[ptr]]) {
      int cur = sta[ptr];
      r[cur] = i;
      ptr--;
    }
    if (ptr == 0)
      l[i] = 0;
    else
      l[i] = sta[ptr];
    sta[++ptr] = i;
    r[i] = n + 1;
  }
  for (int i = 1; i <= n; i++) maxed[i] = -1;
  for (int i = 1; i <= n; i++) {
    int len = r[i] - l[i] - 1;
    maxed[len] = max(maxed[len], num[i]);
  }
  for (int i = n; i >= 1; i--) maxed[i] = max(maxed[i + 1], maxed[i]);
  for (int i = 1; i <= n; i++) cout << maxed[i] << " ";
}
