#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
const int MAX_N = int(3e5) + 10;
int n;
int a[MAX_N];
int even[MAX_N];
int odd[MAX_N];
struct Tree {
  int l, r;
  Tree *pl, *pr;
  int mx;
  void update() { mx = max(pl->mx, pr->mx); }
  Tree(int l, int r, int seq[]) : l(l), r(r) {
    if (l + 1 == r) {
      mx = seq[l];
      return;
    }
    pl = new Tree(l, (l + r) / 2, seq);
    pr = new Tree((l + r) / 2, r, seq);
    update();
  }
  int get(int L, int R) {
    if (L >= R) return -1;
    if (L >= r || l >= R) return -1;
    if (L <= l && R >= r) {
      return mx;
    }
    return max(pl->get(L, R), pr->get(L, R));
  }
} * rodd, *reven;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  for (int i = 0; i < n; i++) {
    if (i + 1 < n) even[i] = max(a[i], a[i + 1]);
    if (i > 0 && i + 1 < n)
      odd[i] = max(min(a[i - 1], a[i]), min(a[i], a[i + 1]));
  }
  rodd = new Tree(0, n, odd);
  reven = new Tree(0, n, even);
  for (int k = 0; k < n; k++) {
    int len = n - k;
    int ans;
    if (len % 2 == 0) {
      ans = reven->get(len / 2 - 1, k + 1 + len / 2 - 1);
    } else {
      if (len == 1) {
        ans = *max_element(a, a + n);
      } else {
        ans = rodd->get(len / 2, k + 1 + len / 2);
      }
    }
    printf("%d ", ans);
  }
  puts("");
  return 0;
}
