#include <bits/stdc++.h>
using namespace std;
int T, n, m, k, q, dp[2][300010], ans[300010], a[300010];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), ans[1] = max(ans[1], a[i]);
  for (int i = 1; i < n; i++)
    dp[1][min(i, n - i)] = max(dp[1][min(i, n - i)], max(a[i], a[i + 1]));
  for (int i = 2; i < n; i++)
    dp[0][min(i - 1, n - i)] =
        max(dp[0][min(i - 1, n - i)],
            max(min(a[i - 1], a[i]), min(a[i], a[i + 1])));
  for (int i = n / 2; i >= 1; i--) {
    ans[i * 2] = max(ans[i * 2 + 2], dp[1][i]);
    ans[i * 2 + 1] = max(ans[i * 2 + 3], dp[0][i]);
  }
  for (int i = 0; i < n; i++) printf("%d\n", ans[n - i]);
}
