#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 300010;
int N;
int A[MAX_N];
int second_row_e[MAX_N], second_row_o[MAX_N];
int survives_e[MAX_N], survives_o[MAX_N];
int max_in_row_e[MAX_N], max_in_row_o[MAX_N];
int indexes[MAX_N];
bool cmp(const int &a, const int &b) { return A[a] > A[b]; }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < N - 1; i++) {
    if (A[i] < A[i + 1]) {
      second_row_e[i] = i + 1;
      survives_e[i] = 0;
    } else {
      second_row_e[i] = i;
      survives_e[i + 1] = 0;
    }
    if (A[i] < A[i + 1]) {
      second_row_o[i] = i;
      survives_o[i + 1] = 0;
    } else {
      second_row_o[i] = i + 1;
      survives_o[i] = 0;
    }
  }
  for (int i = 0; i < N - 1; i++) {
    int tmp = 1 + 2 * min(i, N - 2 - i);
    if ((i > (N - 2) / 2 && A[second_row_e[i]] <= A[second_row_e[i - 1]]) ||
        (i < (N - 2) / 2 && A[second_row_e[i]] <= A[second_row_e[i + 1]]))
      ++tmp;
    survives_e[second_row_e[i]] = max(survives_e[second_row_e[i]], tmp);
    tmp = 1 + 2 * min(i, N - 2 - i);
    if ((i > (N - 2) / 2 && A[second_row_o[i]] >= A[second_row_o[i - 1]]) ||
        (i <= (N - 2) / 2 && A[second_row_o[i]] >= A[second_row_o[i + 1]]))
      ++tmp;
    survives_o[second_row_o[i]] = max(survives_o[second_row_o[i]], tmp);
  }
  for (int i = 0; i < N; i++) indexes[i] = i;
  sort(indexes, indexes + N, cmp);
  int k = 0;
  for (int i = 0; i < N; i++) {
    for (; k <= survives_e[indexes[i]]; k++) max_in_row_e[k] = A[indexes[i]];
  }
  k = 0;
  for (int i = 0; i < N; i++) {
    for (; k <= survives_o[indexes[i]]; k++) max_in_row_o[k] = A[indexes[i]];
  }
  for (int i = 0; i < N; i++) {
    if ((N - i) % 2 == 0)
      cout << max_in_row_e[N - 1 - i] << " ";
    else
      cout << max_in_row_o[N - 1 - i] << " ";
  }
  cout << "\n";
  return 0;
}
