#include <bits/stdc++.h>
using namespace std;
namespace io {
const int SIZE = (1 << 21) + 1;
char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c,
                                       qu[55];
int f, qr;
inline void flush() {
  fwrite(obuf, 1, oS - obuf, stdout);
  oS = obuf;
}
inline void putc(char x) {
  *oS++ = x;
  if (oS == oT) flush();
}
template <class I>
inline void gi(I &x) {
  for (f = 1, c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                              (iS == iT ? EOF : *iS++))
                            : *iS++);
       c < '0' || c > '9';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    if (c == '-') f = -1;
  for (x = 0; c <= '9' && c >= '0';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    x = (x << 1) + (x << 3) + (c & 15);
  x *= f;
}
template <class I>
inline void get(I &x) {
  for (c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++);
       c < 'A' || c > 'Z';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    ;
  x = c;
}
inline void read(char *s) {
  for (c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++);
       c < 'A' || c > 'Z';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    ;
  for (; c >= 'A' && c <= 'Z';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    *++s = c;
  *++s = '\0';
}
template <class I>
inline void print(I x) {
  if (!x) putc('0');
  if (x < 0) putc('-'), x = -x;
  while (x) qu[++qr] = x % 10 + '0', x /= 10;
  while (qr) putc(qu[qr--]);
}
struct Flusher_ {
  ~Flusher_() { flush(); }
} io_flusher_;
}  // namespace io
using io ::get;
using io ::gi;
using io ::print;
using io ::putc;
using io ::read;
const int N = 3e5 + 5;
int a[N], v[2][N];
inline void chmax(int &x, register int y) { x = x > y ? x : y; }
int main() {
  register int n, i, j, l, r, mx;
  gi(n);
  mx = 0;
  for (i = 1; i <= n; ++i) gi(a[i]), mx = max(mx, a[i]);
  for (i = 1; i <= n; ++i) {
    l = i - 1;
    r = n - i;
    if (l > r) swap(l, r);
    chmax(v[1][r - l], a[i]);
  }
  for (i = 1; i < n; ++i) {
    l = i - 1;
    r = n - (i + 1);
    if (l > r) swap(l, r);
    chmax(v[0][r - l], min(a[i], a[i + 1]));
  }
  for (i = 1; i <= n; ++i)
    for (j = 0; j <= 1; ++j) chmax(v[j][i], v[j][i - 1]);
  for (i = 0; i < n; ++i)
    print(i == n - 1 ? mx : v[n - (i + 1) & 1][i + 1]), putc(' ');
  putc('\n');
  return 0;
}
