#include <bits/stdc++.h>
using namespace std;
const int MAXN = 300000;
const int LOG = 19;
int n;
int arr[MAXN];
int mid2[MAXN];
int mid3[MAXN];
int nes2[LOG][MAXN];
int nes3[LOG][MAXN];
void build() {
  int l, i;
  for (i = 0; i < n; ++i) nes2[0][i] = mid2[i], nes3[0][i] = mid3[i];
  for (l = 1; l < LOG; ++l)
    for (i = 0; i + (1 << l) <= n; ++i) {
      nes2[l][i] = max(nes2[l - 1][i], nes2[l - 1][i + (1 << (l - 1))]);
      nes3[l][i] = max(nes3[l - 1][i], nes3[l - 1][i + (1 << (l - 1))]);
    }
}
int query(int nes[LOG][MAXN], int lo, int hi) {
  int l = 31 - __builtin_clz(hi - lo);
  return max(nes[l][lo], nes[l][hi - (1 << l)]);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int i, k;
  cin >> n;
  for (i = 0; i < n; ++i) cin >> arr[i];
  for (i = 0; i + 1 < n; ++i) mid2[i] = max(arr[i], arr[i + 1]);
  for (i = 0; i + 2 < n; ++i)
    mid3[i] = min(arr[i + 1], max(arr[i], arr[i + 2]));
  build();
  for (k = 0; k < n - 1; ++k) {
    if ((n - k) % 2 == 0)
      cout << query(nes2, (n - k) / 2 - 1, (n + k) / 2) << ' ';
    else
      cout << query(nes3, (n - k - 3) / 2, (n + k - 1) / 2) << ' ';
  }
  cout << *max_element(arr, arr + n) << '\n';
}
