#include <bits/stdc++.h>
using namespace std;
const int N = 300010;
int n;
int a[N], b[N], c[N], ans[N];
struct seg {
  int tree[N << 2];
  void build(int l, int r, int x, int *a) {
    if (l == r) {
      tree[x] = a[l];
      return;
    }
    int mid = (l + r) >> 1;
    build(l, mid, x << 1, a);
    build(mid + 1, r, x << 1 | 1, a);
    tree[x] = max(tree[x << 1], tree[x << 1 | 1]);
  }
  int query(int l, int r, int x, int a, int b) {
    if (l > b || r < a) return 0;
    if (l >= a && r <= b) return tree[x];
    int mid = (l + r) >> 1;
    return max(query(l, mid, x << 1, a, b),
               query(mid + 1, r, x << 1 | 1, a, b));
  }
} t1, t2;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (int i = 1; i <= n; ++i) {
    ans[n - 1] = max(ans[n - 1], a[i]);
    b[i] = min(a[i], max(a[i - 1], a[i + 1]));
    c[i] = max(a[i], a[i + 1]);
  }
  t1.build(1, n, 1, b);
  t2.build(1, n, 1, c);
  int l1, r1, l2, r2;
  if (n % 2 == 0) {
    l1 = n / 2;
    r1 = l1 + 1;
    l2 = r2 = n / 2;
  } else {
    l1 = r1 = (n + 1) / 2;
    l2 = n / 2;
    r2 = l2 + 1;
  }
  for (int k = 0; k < n - 1; ++k) {
    if ((n - k) % 2 == 1) {
      ans[k] = t1.query(1, n, 1, l1, r1);
      --l1;
      ++r1;
    } else {
      ans[k] = t2.query(1, n, 1, l2, r2);
      --l2;
      ++r2;
    }
  }
  for (int i = 0; i < n; ++i) printf("%d ", ans[i]);
  return 0;
}
