#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 25, inf = 2e9, M = 1e9 + 7;
int dp[maxn], ind = 1;
int main() {
  int n;
  cin >> n;
  pair<int, int> a[n];
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    a[i] = {x, i + 1};
  }
  sort(a, a + n);
  for (int i = n - 1; i > -1; i--) {
    int pos = a[i].second, val = a[i].first;
    dp[pos] = dp[pos - 1] + dp[pos + 1] + 1;
    if (dp[pos - 1] > 0) {
      dp[pos - dp[pos - 1]] = dp[pos];
    }
    if (dp[pos + 1] > 0) {
      dp[pos + dp[pos + 1]] = dp[pos];
    }
    while (dp[pos] >= ind) {
      cout << val << " ";
      ind++;
    }
  }
  return 0;
}
