#include <bits/stdc++.h>
using namespace std;
const int max_N = 3e5 + 10;
const int l_N = 20;
int inp[max_N];
int neigh[max_N];
int lg[max_N];
struct sparse_table {
  vector<vector<int> > st;
  sparse_table(int *arr, int N);
  int query(int i, int j);
};
int main() {
  int lg = 0;
  for (int i = 1; i < max_N; ++i) {
    while ((1 << lg) <= i) {
      ++lg;
    }
    --lg;
    ::lg[i] = lg;
  }
  int N;
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) {
    scanf("%d", inp + i);
  }
  for (int i = 1; i <= N; ++i) {
    neigh[i] = min(inp[i], max(inp[i - 1], inp[i + 1]));
  }
  sparse_table even(inp, N);
  sparse_table odd(neigh, N);
  cerr << odd.query(5, 36) << endl;
  for (int k = 0; k < N; ++k) {
    int M = N - k;
    if (M == 1) {
      printf("%d ", even.query(1, N));
    } else if (M % 2) {
      int lb = (1 + M) / 2;
      int ub = (N - M + 1 + N) / 2;
      printf("%d ", odd.query(lb, ub));
    } else {
      int lb = (1 + M) / 2;
      int ub = (N - M + 1 + N) / 2 + 1;
      printf("%d ", even.query(lb, ub));
    }
  }
}
sparse_table::sparse_table(int *arr, int N) : st(l_N, vector<int>(N + 1, -1)) {
  for (int i = 1; i <= N; ++i) {
    st[0][i] = arr[i];
  }
  for (int j = 1; (1 << j) <= N; ++j) {
    for (int i = 1; i <= N && i + (1 << j) - 1 <= N; ++i) {
      st[j][i] = max(st[j - 1][i], st[j - 1][i + (1 << (j - 1))]);
    }
  }
}
int sparse_table::query(int i, int j) {
  int k = lg[j - i + 1];
  return max(st[k][i], st[k][j - (1 << k) + 1]);
}
