#include <bits/stdc++.h>
using namespace std;
const double PI = 2.0 * acos(0.0);
const double EPS = 1e-9;
int cases = 1;
double getdist(pair<int, int> a, pair<int, int> b) {
  return sqrt(pow((double)a.first - b.first, 2) +
              pow((double)a.second - b.second, 2));
}
const int MAX = 200000 + 5;
int arr[MAX], ret[MAX], n;
pair<int, int> tree[MAX * 4];
void Read() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &arr[i]);
  return;
}
void build(int node, int b, int e) {
  if (b == e) {
    tree[node] = make_pair(arr[b], b);
    return;
  }
  int left = node << 1, right = left + 1, mid = (b + e) / 2;
  build(left, b, mid);
  build(right, mid + 1, e);
  if (tree[left].first < tree[right].first)
    tree[node] = tree[left];
  else
    tree[node] = tree[right];
  return;
}
pair<int, int> query(int node, int b, int e, int& i, int& j) {
  if (b > j or e < i) return make_pair(1000000000, 0);
  if (b >= i and e <= j) return tree[node];
  int left = node << 1, right = left + 1, mid = (b + e) / 2;
  pair<int, int> tmp1 = query(left, b, mid, i, j);
  pair<int, int> tmp2 = query(right, mid + 1, e, i, j);
  if (tmp1.first < tmp2.first) return tmp1;
  return tmp2;
}
void rec(int left, int right) {
  if (left > right) return;
  if (left == right) {
    pair<int, int> tmp = query(1, 1, n, left, right);
    ret[1] = max(ret[1], tmp.first);
    return;
  }
  pair<int, int> tmp = query(1, 1, n, left, right);
  ret[right - left + 1] = max(ret[right - left + 1], tmp.first);
  rec(left, tmp.second - 1);
  rec(tmp.second + 1, right);
  return;
}
int main() {
  int test;
  memset(ret, -1, sizeof(ret));
  Read();
  build(1, 1, n);
  rec(1, n);
  for (int i = n - 1; i > 0; i--) ret[i] = max(ret[i], ret[i + 1]);
  for (int i = 1; i <= n; i++) printf("%d ", ret[i]);
  return 0;
}
