#include <bits/stdc++.h>
template <typename T>
inline void read(T &x) {
  x = 0;
  char c = getchar();
  bool flag = false;
  while (!isdigit(c)) {
    if (c == '-') flag = true;
    c = getchar();
  }
  while (isdigit(c)) x = x * 10 + (c ^ 48), c = getchar();
  if (flag) x = -x;
}
using namespace std;
inline int F(int x) { return x < 0 ? -x : x; }
inline void MAX(int &a, int b) {
  if (a < b) a = b;
}
int n;
int a[1001000], mx[1001000];
int main() {
  read(n);
  for (int i = 1; i <= n; ++i) read(a[i]);
  for (int i = 1; i < n; ++i) {
    MAX(mx[F((i - 1) - (n - i - 1))], max(a[i], a[i + 1]));
  }
  for (int i = 2; i < n; ++i) {
    int v = min(a[i], max(a[i - 1], a[i + 1]));
    int ld = i - 2, rd = n - (i + 1);
    MAX(mx[F(ld - rd)], v);
  }
  for (int i = 1; i <= n; ++i) MAX(mx[n - 1], a[i]);
  for (int i = 2; i < n; ++i) MAX(mx[i], mx[i - 2]);
  for (int i = 0; i < n; ++i) printf("%d ", mx[i]);
  puts("");
  return 0;
}
