#include <bits/stdc++.h>
using namespace std;
static inline void canhazfast() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
}
template <typename T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <typename T>
T extgcd(T a, T b, T &x, T &y) {
  T x0 = 1, y0 = 0, x1 = 0, y1 = 1;
  while (b) {
    T q = a / b;
    a %= b;
    swap(a, b);
    x0 -= q * x1;
    swap(x0, x1);
    y0 -= q * y1;
    swap(y0, y1);
  }
  x = x0;
  y = y0;
  return a;
}
int ctz(unsigned x) { return __builtin_ctz(x); }
int ctzll(unsigned long long x) { return __builtin_ctzll(x); }
int clz(unsigned x) { return __builtin_clz(x); }
int clzll(unsigned long long x) { return __builtin_clzll(x); }
int popcnt(unsigned x) { return __builtin_popcount(x); }
int popcntll(unsigned long long x) { return __builtin_popcountll(x); }
int bsr(unsigned x) { return 31 ^ clz(x); }
int bsrll(unsigned long long x) { return 63 ^ clzll(x); }
int a[300016];
int two[300016], tri[300016], ans[300016];
int main() {
  canhazfast();
  int n, f, c;
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  if (n == 1) return cout << a[0], 0;
  for (int i = 1; i < n; ++i) two[i] = max(a[i - 1], a[i]);
  for (int i = 2; i < n; ++i) tri[i - 1] = min(a[i - 1], max(a[i - 2], a[i]));
  if (n % 2) {
    int mid = (n - 1) / 2;
    ans[0] = tri[mid];
    ans[1] = max(two[mid], two[mid + 1]);
    for (int i = 2; i < n - 1; ++i) {
      int t, h = i / 2;
      if (i % 2)
        t = max(two[mid - h], two[mid + 1 + h]);
      else
        t = max(tri[mid - h], tri[mid + h]);
      ans[i] = max(ans[i - 2], t);
    }
  } else {
    int mr = n / 2, ml = mr - 1;
    ans[0] = two[mr];
    ans[1] = max(tri[ml], tri[mr]);
    for (int i = 2; i < n - 1; ++i) {
      int t, h = i / 2;
      if (i % 2)
        t = max(tri[ml - h], tri[mr + h]);
      else
        t = max(two[mr - h], two[mr + h]);
      ans[i] = max(ans[i - 2], t);
    }
  }
  ans[n - 1] = *max_element(a, a + n);
  for (int i = 0; i < n; ++i) cout << ans[i] << ' ';
  return 0;
}
