#include <bits/stdc++.h>
using namespace std;
int n;
template <typename T>
class RMQ {
 private:
  int n, Log;
  vector<int> calLog;
  vector<vector<T> > sparse;

 public:
  RMQ()
      : n(2e5),
        Log(log2(n) + 1),
        calLog(n + 5, 0),
        sparse(Log + 1, vector<T>(n + 5, 0)){};
  RMQ(int _n)
      : n(_n),
        Log(log2(n) + 1),
        calLog(n + 5, 0),
        sparse(Log + 1, vector<T>(n + 5, 0)){};
  void init(int _n) {
    n = _n, Log = 1 + log2(n), calLog.assign(n + 5, 0),
    sparse.assign(Log + 1, vector<T>(n + 5, 0));
  }
  void preProcess(vector<T>& given) {
    for (int i = 2; i <= n; i++) calLog[i] = 1 + calLog[i / 2];
    for (int i = 0; i < n; i++) sparse[0][i] = given[i];
    for (int i = 1; i <= Log; i++)
      for (int j = 0; j + (1 << (i - 1)) < n; j++)
        sparse[i][j] = min(sparse[i - 1][j], sparse[i - 1][j + (1 << (i - 1))]);
  }
  T getValue(int l, int r) {
    if (l > r) return 0;
    int k = calLog[r - l + 1];
    return min(sparse[k][l], sparse[k][r - (1 << k) + 1]);
  }
};
int BinarySearch(int idx, int val, RMQ<int>& rmq) {
  int lo = idx, hi = n - 1, ans = -1, ans2 = idx;
  while (lo <= hi) {
    int mid = (lo + hi) >> 1;
    if (rmq.getValue(idx, mid) < val)
      hi = mid - 1;
    else
      lo = mid + 1, ans = mid;
  }
  assert(ans != -1);
  lo = 0, hi = idx;
  while (lo <= hi) {
    int mid = (lo + hi) >> 1;
    if (rmq.getValue(mid, idx) < val)
      lo = mid + 1;
    else
      hi = mid - 1, ans2 = mid;
  }
  assert(ans2 <= idx);
  return (ans - ans2 + 1);
}
void solve() {
  cin >> n;
  vector<int> v(n), ans(n + 1, -1);
  for (int& in : v) cin >> in;
  RMQ<int> rmq(n);
  rmq.preProcess(v);
  map<int, vector<int> > mp;
  for (int i = 0; i < n; i++) mp[v[i]].push_back(i);
  int idx = 1;
  vector<pair<int, vector<int> > > vec;
  for (const auto& it : mp) vec.emplace_back(it.first, it.second);
  reverse(vec.begin(), vec.end());
  for (const auto& it : vec) {
    if (it.second.empty()) continue;
    int mx = 0;
    for (const auto& jt : it.second)
      mx = max(mx, BinarySearch(jt, it.first, rmq));
    while (idx <= mx) ans[idx++] = it.first;
  }
  int mn = *min_element(v.begin(), v.end());
  for (int i = 1; i <= n; i++) {
    int val = ans[i] == -1 ? mn : ans[i];
    if (i == 1)
      cout << val;
    else
      cout << " " << val;
  }
  cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int tc = 1;
  while (tc--) {
    solve();
  }
  return 0;
}
