#include <bits/stdc++.h>
const int MAX = 2e5 + 11;
using namespace std;
int N, A[MAX], P[MAX], SZ[MAX], R[MAX];
vector<pair<int, int>> E;
static int get(int x) { return P[x] = (x == P[x]) ? x : get(P[x]); }
static void add(int x, int y, int w) {
  int a = get(x);
  int b = get(y);
  if (a == b) {
    return;
  }
  if (SZ[a] > SZ[b]) {
    swap(a, b);
  }
  P[a] = b;
  SZ[b] += SZ[a];
  R[SZ[b] - 1] = max(R[SZ[b] - 1], w);
}
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &A[i]);
  }
  for (int i = 0; i < N; ++i) {
    SZ[i] = 1;
    P[i] = i;
    R[0] = max(R[0], A[i]);
  }
  for (int i = 0; i < N - 1; ++i) {
    E.push_back({min(A[i], A[i + 1]), i});
  }
  sort(E.rbegin(), E.rend());
  for (int i = 0; i < N - 1; ++i) {
    add(E[i].second, E[i].second + 1, E[i].first);
  }
  for (int i = N - 2; i >= 0; i--) {
    R[i] = max(R[i], R[i + 1]);
  }
  for (int i = 0; i < N; ++i) {
    printf("%d ", R[i]);
  }
  return 0;
}
