#include <bits/stdc++.h>
using namespace std;
int n;
int a[300005];
int res[300005];
int b[5];
int main() {
  cin >> n;
  int najv = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    najv = max(najv, a[i]);
  }
  if (n % 2 == 1) {
    int br = 0;
    int maxi = 0;
    int pos = n / 2;
    for (int i = 0; i < n / 2; i++) {
      int pos1 = pos - i;
      int pos2 = pos + i;
      int sada = 0;
      if (a[pos1] < a[pos1 - 1] && a[pos1] < a[pos1 + 1])
        sada = a[pos1];
      else
        sada = min(max(a[pos1 + 1], a[pos1 - 1]), a[pos1]);
      maxi = max(maxi, sada);
      if (a[pos2] < a[pos2 - 1] && a[pos2] < a[pos2 + 1])
        sada = a[pos2];
      else
        sada = min(max(a[pos2 + 1], a[pos2 - 1]), a[pos2]);
      maxi = max(maxi, sada);
      res[br] = maxi;
      br += 2;
    }
    br = 1;
    maxi = 0;
    pos = n / 2;
    for (int i = 0; i <= n / 2; i++) {
      maxi = max(maxi, a[pos]);
      maxi = max(maxi, a[pos + i + 1]);
      maxi = max(maxi, a[pos - i - 1]);
      res[br] = maxi;
      br += 2;
    }
  } else {
    int br = 1;
    int maxi = 0;
    int pos1 = n / 2;
    int pos2 = n / 2 - 1;
    for (int i = 0; i < n / 2; i++) {
      int sada = 0;
      if (a[pos1] < a[pos1 - 1] && a[pos1] < a[pos1 + 1])
        sada = a[pos1];
      else
        sada = min(max(a[pos1 + 1], a[pos1 - 1]), a[pos1]);
      maxi = max(maxi, sada);
      if (a[pos2] < a[pos2 - 1] && a[pos2] < a[pos2 + 1])
        sada = a[pos2];
      else
        sada = min(max(a[pos2 + 1], a[pos2 - 1]), a[pos2]);
      maxi = max(maxi, sada);
      res[br] = maxi;
      br += 2;
      pos1++;
      pos2--;
    }
    br = 0;
    maxi = 0;
    pos1 = n / 2;
    pos2 = n / 2 - 1;
    for (int i = 0; i < n / 2; i++) {
      maxi = max(maxi, a[pos1]);
      maxi = max(maxi, a[pos2]);
      pos1++;
      pos2--;
      res[br] = maxi;
      br += 2;
    }
  }
  res[n - 1] = najv;
  for (int i = 0; i < n; i++) {
    printf("%d ", res[i]);
  }
  return 0;
}
