#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 7;
int n, a[MAXN], f[MAXN];
int ans[MAXN];
int n1, n2;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  if (n == 1) {
    cout << a[1] << endl;
    return 0;
  }
  for (int i = 2; i < n; i++)
    f[i] = max(min(a[i - 1], a[i]), min(a[i], a[i + 1]));
  if (n % 2 == 1)
    n1 = n - 1, n2 = n;
  else
    n1 = n, n2 = n - 1;
  for (int K = n1, now = (n % 2 == 1 ? a[n / 2 + 1] : 0); K >= 2; K -= 2) {
    now = max(now, a[K / 2]);
    now = max(now, a[n - K / 2 + 1]);
    ans[n - K] = now;
  }
  for (int K = n2, now = (n % 2 == 1 ? f[n / 2 + 1] : 0); K >= 3; K -= 2) {
    now = max(now, f[(K + 1) / 2]);
    now = max(now, f[n - (K + 1) / 2 + 1]);
    ans[n - K] = now;
  }
  ans[n - 1] = ans[n - 2];
  for (int i = 0; i < n; i++) cout << ans[i] << " ";
}
