#include <bits/stdc++.h>
using namespace std;
long long pwr(long long base, long long p, long long mod) {
  long long ans = 1;
  while (p) {
    if (p & 1) ans = (ans * base) % mod;
    base = (base * base) % mod;
    p /= 2;
  }
  return ans;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
const int N = 1000003;
int n, arr[N], ans[N];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &arr[i]);
  for (int i = 1; i <= n; i++) {
    ans[1] = max(ans[1], arr[i]);
    if (i != 1 && i != n &&
        min(arr[i], max(arr[i - 1], arr[i + 1])) == arr[i]) {
      int len = 2 * min(i - 1, n - i) + 1;
      ans[len] = max(ans[len], arr[i]);
    }
    if (i - 2 >= 1 && min(arr[i - 1], max(arr[i - 2], arr[i])) == arr[i]) {
      int len = 2 * min(i - 2, n - i + 1) + 1;
      ans[len] = max(ans[len], arr[i]);
    }
    if (i + 2 <= n && min(arr[i + 1], max(arr[i], arr[i + 2])) == arr[i]) {
      int len = 2 * min(i, n - i - 1) + 1;
      ans[len] = max(ans[len], arr[i]);
    }
    if (i + 1 <= n) {
      int len = 2 * min(i - 1, n - i - 1) + 2;
      ans[len] = max(ans[len], arr[i]);
    }
    if (i - 1 >= 1) {
      int len = 2 * min(i - 2, n - i) + 2;
      ans[len] = max(ans[len], arr[i]);
    }
  }
  for (int i = n; i >= 1; i--) ans[i] = max(ans[i], ans[i + 2]);
  for (int i = n; i >= 1; i--) printf("%d ", ans[i]);
  return 0;
}
