#include <bits/stdc++.h>
using namespace std;
const int MAXN = 300500, INF = 1e9;
const int neutro = 0;
struct RMQ {
  int sz;
  int t[4 * MAXN];
  int &operator[](int p) { return t[sz + p]; }
  void init(int n) {
    sz = 1 << (32 - __builtin_clz(n));
    for (int i = (0); i < (int)(2 * sz); i++) t[i] = neutro;
  }
  void updall() {
    for (int i = ((int)sz) - 1; i >= 0; i--) t[i] = max(t[2 * i], t[2 * i + 1]);
  }
  int get(int i, int j) { return get(i, j, 1, 0, sz); }
  int get(int i, int j, int n, int a, int b) {
    if (j <= a || i >= b) return neutro;
    if (i <= a && b <= j) return t[n];
    int c = (a + b) / 2;
    return max(get(i, j, 2 * n, a, c), get(i, j, 2 * n + 1, c, b));
  }
};
int n, A[MAXN];
RMQ F, S;
int Ans[MAXN];
int main() {
  while (scanf("%d", &n) == 1) {
    for (int i = (0); i < (int)(n); i++) scanf("%d", &A[i]);
    F.init(n);
    S.init(n);
    F[0] = F[n - 1] = S[0] = S[n - 1] = -1;
    for (int i = (1); i < (int)(n - 1); i++) {
      F[i] = max(A[i], min(A[i - 1], A[i + 1]));
      S[i] = min(A[i], max(A[i - 1], A[i + 1]));
    }
    F.updall();
    S.updall();
    for (int k = (0); k < (int)(n - 2); k++) {
      RMQ(&W) = ((n - k) % 2 ? S : F);
      int p = (n - k - 1) / 2;
      Ans[k] = W.get(p, n - p);
    }
    int rr = -1;
    for (int i = (0); i < (int)(n); i++) rr = max(rr, A[i]);
    Ans[n - 1] = rr;
    if (n > 1) Ans[n - 2] = rr;
    for (int i = (0); i < (int)(n); i++) {
      if (i) printf(" ");
      printf("%d", Ans[i]);
    }
    puts("");
  }
  return 0;
}
