#include <bits/stdc++.h>
const int N = 1e5 + 5;
using namespace std;
int aa[26], bb[26], cc[26];
int a[200005], ans[200005];
int main() {
  stack<pair<int, int> > s;
  int n, i;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i];
  a[n + 1] = -1;
  for (i = 1; i <= n + 1; i++) {
    int len = 0;
    while (!s.empty()) {
      if (s.top().first < a[i]) break;
      len += s.top().second;
      ans[len] = max(ans[len], s.top().first);
      s.pop();
    }
    s.push(make_pair(a[i], len + 1));
  }
  for (i = n - 1; i >= 1; i--) {
    ans[i] = max(ans[i], ans[i + 1]);
  }
  for (i = 1; i <= n; i++) {
    cout << ans[i] << ' ';
  }
  cout << endl;
  return 0;
}
