#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int a[N], sp[N][20], n, lg[N];
int tree[4 * N];
void update(int i, int l, int r, int a, int b, int v) {
  if (l > b || r < a) return;
  if (l >= a && r <= b) return void(tree[i] = max(tree[i], v));
  int mid = (l + r) >> 1;
  update(i << 1, l, mid, a, b, v);
  update(i << 1 | 1, mid + 1, r, a, b, v);
}
void pre() {
  for (int i = 0; 1 << i < N; i++) lg[1 << i] = i;
  for (int i = 1; i < N; i++) lg[i] = max(lg[i], lg[i - 1]);
  for (int i = 0; i < N; i++)
    for (int j = 0; j < 20; j++) sp[i][j] = 2e9;
}
void build() {
  for (int i = 0; i < n; i++) sp[i][0] = a[i];
  for (int i = 1; i <= 18; i++)
    for (int j = 0; j < n; j++) {
      sp[j][i] = sp[j][i - 1];
      if (j + (1 << (i - 1)) < n)
        sp[j][i] = min(sp[j][i], sp[j + (1 << (i - 1))][i - 1]);
      else
        break;
    }
}
int get(int l, int r) {
  int k = lg[r - l + 1];
  return min(sp[l][k], sp[r - (1 << k) + 1][k]);
}
int bs1(int i) {
  int ans = i;
  int s = i, e = n - 1;
  while (s <= e) {
    int mid = (s + e) >> 1;
    int mi = get(i, mid);
    if (mi >= a[i])
      s = mid + 1, ans = mid;
    else
      e = mid - 1;
  }
  return ans - i;
}
int bs2(int i) {
  int ans = i;
  int s = 0, e = i;
  while (s <= e) {
    int mid = (s + e) >> 1;
    int mi = get(mid, i);
    if (mi >= a[i])
      e = mid - 1, ans = mid;
    else
      s = mid + 1;
  }
  return i - ans;
}
void print(int i, int l, int r, int v = 0) {
  if (l == r) {
    cout << max(tree[i], v) << " ";
    return;
  }
  int mid = (l + r) >> 1;
  print(i << 1, l, mid, max(v, tree[i]));
  print(i << 1 | 1, mid + 1, r, max(v, tree[i]));
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  pre();
  build();
  for (int i = 0; i < n; i++) {
    int right = bs1(i);
    int left = bs2(i);
    update(1, 1, n, 1, right + left + 1, a[i]);
  }
  print(1, 1, n);
  return 0;
}
