#include <bits/stdc++.h>
using namespace std;
int mx[2][300030][20], N, a[300030], b[300030];
void pre() {
  for (int i = 0; i < N; i++) mx[0][i][0] = a[i], mx[1][i][0] = b[i];
  for (int j = 1; j < 20; j++) {
    for (int i = 0; i < N; i++) {
      for (int k = 0; k < 2; k++)
        mx[k][i][j] =
            max(mx[k][i][j - 1], mx[k][min(N, i + (1 << j - 1))][j - 1]);
    }
  }
}
int calc(int L, int R, int tp) {
  int l = 31 - __builtin_clz(R - L + 1);
  return max(mx[tp][L][l], mx[tp][R - (1 << l) + 1][l]);
}
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d", a + i);
  }
  b[0] = a[0];
  b[N - 1] = a[N - 1];
  for (int i = 1; i < N - 1; i++) {
    if (a[i] <= a[i - 1] && a[i] <= a[i + 1])
      b[i] = a[i];
    else
      b[i] = max(min(a[i - 1], a[i]), min(a[i], a[i + 1]));
  }
  pre();
  for (int i = 0; i < N; i++) {
    if ((N - i) % 2 == 0) {
      int l = (N - i) / 2 - 1;
      int r = N - (N - i) / 2;
      printf("%d ", calc(l, r, 0));
    } else {
      if (N - i == 1)
        printf("%d ", calc(0, N - 1, 0));
      else {
        int l = (N - i) / 2;
        int r = N - (N - i) / 2 - 1;
        printf("%d ", calc(l, r, 1));
      }
    }
  }
  return 0;
}
