#include <bits/stdc++.h>
inline int in() {
  int k = 0;
  char ch = getchar();
  while (!isdigit(ch)) ch = getchar();
  while (isdigit(ch)) k = k * 10 + ch - '0', ch = getchar();
  return k;
}
int a[300005], ans[500005], fz[500000];
inline int max(const int &a, const int &b) { return a > b ? a : b; }
inline int min(const int &a, const int &b) { return a < b ? a : b; }
int main() {
  int n = in();
  for (int i = 1; i <= n; ++i) fz[1] = max(fz[1], a[i] = in());
  for (int i = 1; i < n; ++i)
    fz[min(n - i, i) << 1] = max(fz[min(n - i, i) << 1], max(a[i], a[i + 1]));
  for (int i = 2; i <= n; ++i)
    fz[(min(n - i + 1, i) << 1) - 1] = max(fz[(min(n - i + 1, i) << 1) - 1],
                                           min(a[i], max(a[i - 1], a[i + 1])));
  for (int i = n; i; --i) printf("%d ", ans[i] = max(ans[i + 2], fz[i]));
  puts("");
  return 0;
}
