#include <bits/stdc++.h>
using namespace std;
FILE *in;
FILE *out;
const int MAX = 300003;
const int TREE = 1048576;
int n;
int a[MAX];
int tree1[TREE], tree2[TREE];
void update(int tree[TREE], int idx, int val) {
  idx += (TREE >> 1);
  while (idx) {
    tree[idx] = max(tree[idx], val);
    idx >>= 1;
  }
}
int query(int tree[TREE], int idx1, int idx2) {
  idx1 += (TREE >> 1), idx2 += (TREE >> 1);
  if (idx1 == idx2) return tree[idx1];
  int ret = 0;
  ret = max(ret, tree[idx1]);
  bool flag1 = !(idx1 & 1);
  idx1 >>= 1;
  ret = max(ret, tree[idx2]);
  bool flag2 = (idx2 & 1);
  idx2 >>= 1;
  while (idx1 != idx2) {
    if (flag1) ret = max(ret, tree[(idx1 << 1) | 1]);
    flag1 = !(idx1 & 1);
    idx1 >>= 1;
    if (flag2) ret = max(ret, tree[(idx2 << 1) | 0]);
    flag2 = (idx2 & 1);
    idx2 >>= 1;
  }
  return ret;
}
void solve() {
  memset(tree1, 0, sizeof(tree1));
  memset(tree2, 0, sizeof(tree2));
  for (int i = 0; i < n; i++) update(tree1, i, a[i]);
  for (int i = 0; i < n - 1; i++) update(tree2, i, min(a[i], a[i + 1]));
  vector<int> ans;
  for (int k = 0; k < n; k++) {
    if (n - k == 1 || n - k == 2) {
      ans.push_back(query(tree1, 0, n - 1));
    } else {
      int maxLeft = k + 1, maxRight = n - 1;
      int minLeft = 0, minRight = n - 1 - k - 1;
      int idx1 = (minLeft + minRight) / 2;
      int idx2 = (maxLeft + maxRight) / 2;
      ans.push_back(query((n - k) % 2 == 0 ? tree1 : tree2, idx1, idx2));
    }
  }
  for (int i = 0; i < (int)ans.size(); i++)
    fprintf(out, "%d%c", ans[i], i + 1 == (int)ans.size() ? '\n' : ' ');
}
int dyn[1000][1000][2];
int recurse(int left, int right, int who) {
  if (left == right) return a[left];
  if (dyn[left][right][who] != -1) return dyn[left][right][who];
  int ans =
      who == 0
          ? max(recurse(left + 1, right, !who), recurse(left, right - 1, !who))
          : min(recurse(left + 1, right, !who), recurse(left, right - 1, !who));
  return dyn[left][right][who] = ans;
}
void dummy() {
  memset(dyn, -1, sizeof(dyn));
  for (int k = 0; k < n; k++) {
    int maxx = 0;
    for (int l = 0; l <= k; l++)
      maxx = max(maxx, recurse(l, n - (k - l) - 1, 0));
    fprintf(out, "%d%c", maxx, k == n - 1 ? '\n' : ' ');
  }
}
int main(void) {
  in = stdin;
  out = stdout;
  fscanf(in, "%d", &n);
  for (int i = 0; i < n; i++) fscanf(in, "%d", &a[i]);
  solve();
  return 0;
}
