#include <bits/stdc++.h>
using namespace std;
const int MAX = 200005;
int arr[MAX], ans[MAX], s[19][MAX];
void preprocess(int n) {
  for (int i = 0; i < n; ++i) s[0][i] = arr[i];
  for (int i = 1; i <= 18; ++i) {
    for (int j = 0; j + (1 << i) <= n; ++j) {
      s[i][j] = min(s[i - 1][j], s[i - 1][j + (1 << (i - 1))]);
    }
  }
  return;
}
int minimum(int l, int r) {
  int x = log2(r - l + 1);
  return min(s[x][l], s[x][r - (1 << x) + 1]);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", &arr[i]);
  preprocess(n);
  for (int i = 0; i < n; ++i) {
    int from = i, to = i;
    int l = i, r = n - 1;
    while (l <= r) {
      int mid = (l + r) >> 1;
      if (minimum(i, mid) < arr[i])
        r = mid - 1;
      else
        l = mid + 1, to = max(to, mid);
    }
    l = 0, r = i;
    while (l <= r) {
      int mid = (l + r) >> 1;
      if (minimum(mid, i) < arr[i])
        l = mid + 1;
      else
        r = mid - 1, from = min(from, mid);
    }
    ans[to - from + 1] = max(ans[to - from + 1], arr[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]);
  return 0;
}
