#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_gt = priority_queue<T, vector<T>, greater<T>>;
template <typename T>
using pq_lt = priority_queue<T, vector<T>, less<T>>;
int a[300100];
int odd, even;
int n, maxi;
int find(int start, int end) {
  int mid = (start + end) / 2;
  if (start + 1 == end) {
    return maxi;
  }
  if ((end - start) % 2) {
    return max(min(a[mid - 1], a[mid]), min(a[mid], a[mid + 1]));
  } else {
    return max(a[mid - 1], a[mid]);
  }
}
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    maxi = max(maxi, a[i]);
  }
  odd = -1, even = -1;
  for (int i = 0; i < n; i++) {
    int temp = even;
    if ((n - i) % 2) {
      temp = odd;
    }
    int ans = max(find(i, n), temp);
    ans = max(find(0, n - i), ans);
    if ((n - i) % 2) {
      odd = ans;
    } else {
      even = ans;
    }
    cout << ans << " ";
  }
}
