#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const unsigned gen_seed =
    std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937_64 gen(gen_seed);
class stree {
 public:
  std::vector<int> t;
  int s;
  void build(std::vector<int>& a, int v, int tl, int tr) {
    if (v == 1) {
      t.resize(a.size() * 4);
      s = a.size();
    }
    if (tl == tr)
      t[v] = a[tl];
    else {
      int tm = (tl + tr) / 2;
      build(a, v * 2, tl, tm);
      build(a, v * 2 + 1, tm + 1, tr);
      t[v] = max(t[v * 2], t[v * 2 + 1]);
    }
  }
  int get(int v, int tl, int tr, int l, int r) {
    if (l > r) return 0;
    if (tl == l && tr == r) return t[v];
    int tm = (tl + tr) / 2;
    return max(get(v * 2, tl, tm, l, min(r, tm)),
               get(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r));
  }
};
int main() {
  int n;
  scanf("%d", &n);
  std::vector<int> a(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  stree st;
  st.build(a, 1, 0, n - 1);
  std::vector<int> ans(n, 0);
  ans[n - 1] = st.get(1, 0, n - 1, 0, n - 1);
  int k = 1;
  while (n >= 2 * k) {
    ans[n - 2 * k] = st.get(1, 0, n - 1, k - 1, n - k);
    k++;
  }
  std::vector<int> b(n - 1);
  for (int i = 0; i < n - 1; i++) b[i] = min(a[i], a[i + 1]);
  if (n > 2) {
    st.build(b, 1, 0, n - 2);
    int k = 1;
    while (n >= 2 * k + 1) {
      ans[n - 2 * k - 1] = st.get(1, 0, n - 2, k - 1, n - 1 - k);
      k++;
    }
  }
  for (int i = 0; i < n; i++) printf("%d ", ans[i]);
}
