#include <bits/stdc++.h>
using namespace std;
long long XXX[300001][11][2];
long long *xxx;
long long answer(long long *a, long long *b, long long k) {
  if (a == b) return a[0];
  if (b - a > 10) {
    long long c = (b - a) / 2 - 3;
    return answer(a + c, b - c, k);
  }
  if (XXX[a - xxx][b - a][k] != 0) return XXX[a - xxx][b - a][k];
  if (k == 0)
    return XXX[a - xxx][b - a][k] =
               max(answer(a + 1, b, 1 - k), answer(a, b - 1, 1 - k));
  return XXX[a - xxx][b - a][k] =
             min(answer(a + 1, b, 1 - k), answer(a, b - 1, 1 - k));
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  long long n;
  cin >> n;
  long long a[n];
  xxx = a;
  for (long long &i : a) cin >> i;
  long long ans[n];
  fill_n(ans, n, 0);
  if (n * n < 50000)
    for (long long i = 0; i < n; i++) {
      for (long long j = i; j < n; j++) {
        ans[n - (j - i + 1)] =
            max(ans[n - (j - i + 1)], answer(a + i, a + j, 0));
      }
    }
  for (long long i = 0; i < n; i++) {
    if (min(i, n - i) < 10)
      for (long long j = i; j < n; j++) {
        ans[n - (j - i + 1)] =
            max(ans[n - (j - i + 1)], answer(a + i, a + j, 0));
      }
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = i; j < n && j < i + 10; j++) {
      ans[n - (j - i + 1)] = max(ans[n - (j - i + 1)], answer(a + i, a + j, 0));
    }
  }
  for (long long i = 0; i < n; i++) {
    long long c = min(i, n - i);
    for (long long x = i - c - 1; x <= i - c + 1; x++) {
      for (long long y = i + c - 1; y <= i + c + 1; y++) {
        if (x <= y && x >= 0 && y < n)
          ans[n - (y - x + 1)] =
              max(ans[n - (y - x + 1)], answer(a + x, a + y, 0));
      }
    }
  }
  for (long long i = 0; i < n; i++) {
    if (i - 2 >= 0) ans[i] = max(ans[i], ans[i - 2]);
    cout << ans[i] << " ";
  }
}
