#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)(3e5 + 123);
const int inf = (int)(1e9 + 7);
int n, a[maxn], k, t[2][4 * maxn], e[maxn], o[maxn];
void update(int v, int l, int r, int pos, int x, int k) {
  if (l == r) {
    t[k][v] = x;
    return;
  }
  int m = (l + r) / 2;
  if (m >= pos)
    update(2 * v, l, m, pos, x, k);
  else
    update(2 * v + 1, m + 1, r, pos, x, k);
  if (k) t[k][v] = min(t[k][2 * v], t[k][2 * v + 1]);
  t[k][v] = max(t[k][2 * v], t[k][2 * v + 1]);
}
int getmin(int v, int l, int r, int al, int ar, int k) {
  if (al > r || ar < l) return inf;
  if (l >= al && r <= ar) return t[k][v];
  int m = (l + r) / 2;
  return min(getmin(2 * v, l, m, al, ar, k),
             getmin(2 * v + 1, m + 1, r, al, ar, k));
}
int getmax(int v, int l, int r, int al, int ar, int k) {
  if (al > r || ar < l) return -inf;
  if (l >= al && r <= ar) {
    return t[k][v];
  }
  int m = (l + r) / 2;
  return max(getmax(2 * v, l, m, al, ar, k),
             getmax(2 * v + 1, m + 1, r, al, ar, k));
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  for (int i = 2; i <= n; ++i) {
    e[i] = max(a[i], a[i - 1]);
    update(1, 1, n, i, e[i], 0);
  }
  for (int i = 2; i < n; ++i) {
    o[i] = max(min(a[i + 1], a[i]), min(a[i], a[i - 1]));
    update(1, 1, n, i, o[i], 1);
  }
  for (int k = 0; k < n - 1; ++k) {
    if ((n - k) % 2) {
      cout << getmax(1, 1, n, (n - k) / 2 + 1, (n - k) / 2 + 1 + k, 1) << "\n";
    } else {
      cout << getmax(1, 1, n, (n - k) / 2 + 1, (n - k) / 2 + k + 1, 0) << "\n";
    }
  }
  sort(a + 1, a + n + 1);
  cout << a[n];
  return 0;
}
