#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m, l, r, ans = 0, cur, c0, c1;
  cin >> n;
  l = 0;
  r = n - 1;
  m = 2 * n - 2;
  cur = m / 2;
  c0 = 0;
  c1 = 1;
  vector<int> a(n * 2), mo, a0(n * 2), a1(n * 2);
  for (int i = 0; i < n; i++) {
    cin >> a[i * 2];
    ans = max(ans, a[i * 2]);
  }
  for (int i = 1; i < m; i += 2) a0[i] = max(a[i - 1], a[i + 1]);
  for (int i = 2; i < m; i += 2)
    a1[i] = max(min(a[i - 2], a[i]), min(a[i], a[i + 2]));
  c0 = max(c0, a0[cur]);
  c1 = max(c1, a1[cur]);
  for (int i = 0; i < n - 1; i++) {
    c0 = max(c0, max(a0[cur - i], a0[cur + i]));
    c1 = max(c1, max(a1[cur - i], a1[cur + i]));
    if ((n - i) & 1)
      cout << c1 << ' ';
    else
      cout << c0 << ' ';
  }
  cout << ans << '\n';
}
