#include <bits/stdc++.h>
using namespace std;
class segtree {
 public:
  static const int N = 1 << 19;
  int dp[1 << 20];
  segtree() { memset(dp, 0, sizeof(dp)); }
  void update(int k, int v) {
    k += N - 1;
    dp[k] += v;
    while (k > 0) {
      k = (k - 1) / 2;
      dp[k] = max(dp[k * 2 + 1], dp[k * 2 + 2]);
    }
  }
  int query(int a, int b, int k = 0, int l = 0, int r = N) {
    if (b <= l || r <= a) return 0;
    if (a <= l && r <= b) return dp[k];
    int mid = (l + r) / 2;
    int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
    int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
    return max(vl, vr);
  }
};
segtree eve, odd;
int n;
int a[300005];
int main(void) {
  scanf("%d", &n);
  int ma = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    ma = max(ma, a[i]);
  }
  for (int i = 0; i < n - 1; i++) {
    eve.update(i, max(a[i], a[i + 1]));
  }
  for (int i = 0; i < n - 2; i++) {
    odd.update(i, min(a[i + 1], max(a[i], a[i + 2])));
  }
  for (int i = 0; i < n; i++) {
    int x = (n - i) / 2;
    if ((n - i) % 2 == 0) {
      printf("%d%c", eve.query(x - 1, n - x), i + 1 == n ? '\n' : ' ');
    } else {
      if (i == n - 1)
        printf("%d\n", ma);
      else
        printf("%d%c", odd.query(x - 1, n - 1 - x), i + 1 == 0 ? '\n' : ' ');
    }
  }
  return 0;
}
