#include <bits/stdc++.h>
using namespace std;
struct rec {
  int l, r;
};
int n, a[300005], i, j, k, maxi[1200005], ans[300005];
rec tree[1200005];
int min(int a, int b) {
  if (a < b)
    return a;
  else
    return b;
}
int max(int a, int b) {
  if (a < b)
    return b;
  else
    return a;
}
void pushup(int rt) { maxi[rt] = max(maxi[rt << 1], maxi[rt << 1 | 1]); }
void build(int rt, int l, int r) {
  tree[rt].l = l;
  tree[rt].r = r;
  if (l == r) return;
  int mid = (l + r) >> 1;
  build(rt << 1, l, mid);
  build(rt << 1 | 1, mid + 1, r);
}
void update(int rt, int l, int c) {
  if (tree[rt].l == tree[rt].r) {
    maxi[rt] = c;
    return;
  }
  int mid = (tree[rt].l + tree[rt].r) >> 1;
  if (l <= mid) {
    update(rt << 1, l, c);
  } else {
    update(rt << 1 | 1, l, c);
  }
  pushup(rt);
}
int query(int rt, int l, int r) {
  if ((tree[rt].l == l) && (r == tree[rt].r)) {
    return maxi[rt];
  }
  int mid = (tree[rt].l + tree[rt].r) >> 1;
  int t1, t2;
  if (r <= mid) {
    return query(rt << 1, l, r);
  } else if (l > mid) {
    return query(rt << 1 | 1, l, r);
  } else {
    t1 = query(rt << 1, l, mid);
    t2 = query(rt << 1 | 1, mid + 1, r);
    return max(t1, t2);
  }
}
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  build(1, 1, n);
  for (i = 2; i <= n - 1; i++) {
    update(1, i, min(a[i], max(a[i - 1], a[i + 1])));
  }
  for (k = 0; k <= n - 2; k++) {
    if (((n - k) & 1) == 1) {
      ans[k] = query(1, (n + 1 - k) >> 1, (n + 1 + k) >> 1);
    }
  }
  for (i = 1; i <= n; i++) {
    if (a[i] > ans[n - 1]) ans[n - 1] = a[i];
  }
  memset(maxi, 0, sizeof(maxi));
  for (i = 1; i <= n - 1; i++) {
    update(1, i, max(a[i], a[i + 1]));
  }
  for (k = 0; k <= n - 2; k++) {
    if (((n - k) & 1) == 0) {
      ans[k] = query(1, (n + 1 - k) >> 1, (n + 1 + k) >> 1);
    }
  }
  for (i = 0; i <= n - 1; i++) {
    printf("%d ", ans[i]);
  }
  return 0;
}
