#include <bits/stdc++.h>
const long long oo = 2 * 1000 * 1000 * 1000;
const int _cnt = 1000 * 1000;
const int _p = 1000 * 1000 * 1000 + 7;
int o(int x) { return x % _p; }
int gcd(int a, int b) { return (a % b) ? gcd(b, a % b) : b; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
using namespace std;
void file_put() {
  freopen("filename.in", "r", stdin);
  freopen("filename.out", "w", stdout);
}
int n, a[200005], b[200005], cnt = 0, ans[200005];
map<int, int> M, N;
vector<int> V[200005];
set<int> S;
multiset<int> T;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
  for (int i = 1; i <= n; i++) a[i] = b[i];
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++) {
    if (!M[a[i]]) {
      M[a[i]] = ++cnt;
      N[cnt] = a[i];
    }
  }
  for (int i = 1; i <= n; i++) b[i] = M[b[i]];
  for (int i = 1; i <= n; i++) V[b[i]].push_back(i);
  for (int i = 0; i <= n + 1; i++) S.insert(i);
  for (int i = 1; i <= n + 1; i++) T.insert(1);
  for (int i = cnt; i >= 1; i--) {
    ans[i] = *T.rbegin();
    for (int j = 0; j < V[i].size(); j++) {
      auto it = S.find(V[i][j]);
      auto p = it, q = it;
      p--, q++;
      T.erase(T.find(*it - *p));
      T.erase(T.find(*q - *it));
      T.insert(*q - *p);
      S.erase(it);
    }
  }
  ans[0] = n + 1;
  for (int i = cnt; i >= 1; i--) {
    int x = N[i];
    for (int j = ans[i]; j <= ans[i - 1] - 1; j++) printf("%d ", x);
  }
  printf("\n");
  return 0;
}
