#include <bits/stdc++.h>
using namespace std;
int n, a[300005], A[20][300005], B[20][300005];
int query(int E[20][300005], int l, int r) {
  int t = (int)(log2(r - l + 1));
  return max(E[t][l], E[t][r - (1 << t) + 1]);
}
int main() {
  int i, j;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (i = 1; i <= n; i++) {
    A[0][i] = a[i];
    B[0][i] = min(a[i], max(a[i - 1], a[i + 1]));
  }
  for (i = 1; i < 20; i++)
    for (j = 1; j <= n; j++) {
      A[i][j] = A[i - 1][j];
      B[i][j] = B[i - 1][j];
      if (j + (1 << (i - 1)) <= n) {
        A[i][j] = max(A[i][j], A[i - 1][j + (1 << (i - 1))]);
        B[i][j] = max(B[i][j], B[i - 1][j + (1 << (i - 1))]);
      }
    }
  for (i = 0; i < n - 1; i++)
    if ((n - i) % 2 == 0)
      printf("%d ", query(A, (n - i) / 2, n - (n - i) / 2 + 1));
    else
      printf("%d ", query(B, (n - i + 1) / 2, n - (n - i) / 2));
  printf("%d", A[19][1]);
  return 0;
}
