#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 50;
int n, mxa;
int a[maxn];
int ans[2][maxn];
int sol[maxn];
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    mxa = max(mxa, a[i]);
  }
  for (int i = 1; i < n - 1; i++) {
    ans[0][i] = min(a[i], max(a[i - 1], a[i + 1]));
  }
  for (int i = 0; i < n - 1; i++) {
    ans[1][i] = max(a[i], a[i + 1]);
  }
  int l = (n + 1) / 2 - 1, r = (n + 1) / 2 - 1 + (n % 2 == 0), mx = 0;
  while (l >= 1 && r < n - 1) {
    mx = max(mx, ans[0][l]);
    mx = max(mx, ans[0][r]);
    sol[n - (r - l + 1)] = mx;
    l--;
    r++;
  }
  l = n / 2 - 1, r = n / 2 - (n % 2 == 0), mx = 0;
  while (l >= 0 && r < n - 1) {
    mx = max(mx, ans[1][l]);
    mx = max(mx, ans[1][r]);
    sol[n - (r - l + 1)] = mx;
    l--;
    r++;
  }
  sol[0] = mxa;
  for (int i = n - 1; i >= 0; i--) {
    cout << sol[i] << ' ';
  }
  return 0;
}
