#include <bits/stdc++.h>
using namespace std;
int maxmin(int subsetsize, int *tmp, int size) {
  int max = 0;
  for (int *j = tmp; j + subsetsize <= tmp + size; j++) {
    int min = -1;
    for (int *i = j; i < j + subsetsize; i++) {
      if (*i < min || min < 0) min = *i;
    }
    if (min > max) max = min;
  }
  return max;
}
int main() {
  int num;
  cin >> num;
  int *vals = (int *)malloc(sizeof(int) * num);
  int n = 0;
  while (n != num) {
    cin >> vals[n];
    n++;
  }
  int minl[num];
  int minr[num];
  long max[num + 1];
  memset(max, 0, sizeof(long) * (num + 1));
  for (int i = 0; i < num; i++) {
    if (i != 0) {
      int u = i - 1;
      while (u >= 0) {
        if (vals[u] < vals[i]) {
          minl[i] = i - u;
          break;
        }
        if (minl[u] == 0) {
          minl[i] = 0;
          break;
        }
        u -= minl[u];
      }
    } else
      minl[i] = 0;
    int j = num - i - 1;
    if (j != num - 1) {
      int u = j + 1;
      while (u < num) {
        if (vals[u] < vals[j]) {
          minr[j] = u - j;
          break;
        }
        if (minr[u] == 0) {
          minr[j] = 0;
          break;
        }
        u += minr[u];
      }
    } else
      minr[j] = 0;
  }
  for (int i = 0; i < num; i++) {
    int l = minl[i] == 0 ? i + 1 : minl[i];
    int r = minr[i] == 0 ? num - i : minr[i];
    if (vals[i] > max[r + l - 1]) max[r + l - 1] = vals[i];
  }
  int lastmax = 0;
  for (int i = num; i > 0; i--) {
    if (max[i] > lastmax)
      lastmax = max[i];
    else
      max[i] = lastmax;
  }
  for (int i = 1; i <= num; i++) cout << max[i] << " ";
  return 0;
}
