#include <bits/stdc++.h>
using namespace std;
const int N = 300007;
struct STtable {
  int n, st[20][N];
  void build(int *f) {
    for (int i = 1, iE = n; i <= iE; i++) st[0][i] = f[i];
    for (int i = 1, iE = 18; i <= iE; i++)
      for (int j = 1, jE = n - (1 << i) + 1; j <= jE; j++)
        st[i][j] = max(st[i - 1][j], st[i - 1][j + (1 << (i - 1))]);
  }
  int query(int l, int r) {
    int p = log2(r - l + 1);
    return max(st[p][l], st[p][r - (1 << p) + 1]);
  }
} F, G;
int n, a[N], f[N], g[N];
int get(int l, int r) {
  if (l == r) return a[l];
  int mid = (l + r) / 2;
  if ((r - l + 1) & 1)
    return max(min(a[mid], a[mid - 1]), min(a[mid], a[mid + 1]));
  else
    return max(a[mid], a[mid + 1]);
}
int main() {
  scanf("%d", &n), F.n = G.n = n;
  for (int i = 1, iE = n; i <= iE; i++) scanf("%d", &a[i]);
  for (int i = 2, iE = n - 1; i <= iE; i++)
    f[i] = max(min(a[i], a[i - 1]), min(a[i], a[i + 1]));
  for (int i = 1, iE = n - 1; i <= iE; i++) g[i] = max(a[i], a[i + 1]);
  F.build(f), G.build(g);
  for (int i = 1, iE = n - 1; i <= iE; i++) {
    int res = 0;
    if ((n - i + 1) & 1)
      printf("%d ", F.query((n - i) / 2 + 1, (i + n) / 2));
    else
      printf("%d ", G.query((n - i) / 2 + 1, (i + n) / 2));
  }
  int res = 0;
  for (int i = 1, iE = n; i <= iE; i++) res = max(res, a[i]);
  printf("%d ", res);
  puts("");
  return 0;
}
