#include <bits/stdc++.h>
using namespace std;
const int N = 300010;
int n, fruitness[N];
int main() {
  int mxF = 0;
  int ans[N];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> fruitness[i];
    mxF = max(mxF, fruitness[i]);
  }
  ans[n - 1] = mxF;
  int ansOdd[N];
  ansOdd[0] = fruitness[0];
  ansOdd[n - 1] = fruitness[n - 1];
  for (int i = 1; i < n - 1; i++) {
    ansOdd[i] = min(fruitness[i], max(fruitness[i - 1], fruitness[i + 1]));
  }
  int even, odd;
  if (n & 1)
    even = n - 1, odd = n;
  else
    even = n, odd = n - 1;
  mxF = 0;
  for (int i = even; i >= 2; i -= 2) {
    int l = (i - 1) / 2, r = n - i / 2;
    mxF = max(mxF, max(fruitness[l], fruitness[r]));
    if (i == even && l + 2 == r) {
      mxF = max(mxF, fruitness[l + 1]);
    }
    ans[n - i] = mxF;
  }
  mxF = 0;
  for (int i = odd; i >= 3; i -= 2) {
    int l = i / 2, r = n - (i + 1) / 2;
    mxF = max(mxF, max(ansOdd[l], ansOdd[r]));
    ans[n - i] = mxF;
  }
  for (int i = 0; i < n; i++) cout << ans[i] << " ";
  cout << endl;
  return 0;
}
