#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int sum = 0;
  char c = getchar();
  bool f = 0;
  while (c < '0' || c > '9') {
    if (c == '-') f = 1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    sum = sum * 10 + c - '0';
    c = getchar();
  }
  if (f) return -sum;
  return sum;
}
const int N = 400005;
int n, a[N], f1[N], f2[N], f[N];
inline void up(int &x, int y) {
  if (y > x) x = y;
}
int main() {
  int i, j = 0;
  n = read();
  for (i = 1; i <= n; i++) a[i] = read(), j = max(j, a[i]);
  for (i = 2; i < n; i++)
    up(f1[min(i - 1, n - i)], min(a[i], max(a[i - 1], a[i + 1])));
  for (i = 2; i < n; i++) up(f2[min(i, n - i)], max(a[i], a[i + 1]));
  for (i = n; i >= 2; i--)
    printf("%d ", f[i] = max(f[i + 2], (i & 1) ? f1[i >> 1] : f2[i >> 1]));
  printf("%d", j);
  return 0;
}
