#include <bits/stdc++.h>
using namespace std;
int const N = 300100;
int main() {
  int n;
  scanf("%d", &n);
  static int a[N];
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  static int ans[N];
  {
    ans[1] = *max_element(a, a + n);
    multiset<int> values;
    for (int i = 1; i < n - 1; ++i) {
      values.insert(min(a[i], max(a[i - 1], a[i + 1])));
    }
    int x = 1, y = n - 2;
    for (int len = 3; len <= n; len += 2) {
      if (len > 3) {
        values.erase(values.find(min(a[x], max(a[x - 1], a[x + 1]))));
        ++x;
        values.erase(values.find(min(a[y], max(a[y - 1], a[y + 1]))));
        --y;
      }
      ans[len] = *--values.end();
    }
  }
  {
    multiset<int> values;
    for (int i = 0; i < n - 1; ++i) {
      values.insert(max(a[i], a[i + 1]));
    }
    int x = 0, y = n - 2;
    for (int len = 2; len <= n; len += 2) {
      if (len > 2) {
        values.erase(values.find(max(a[x], a[x + 1])));
        ++x;
        values.erase(values.find(max(a[y], a[y + 1])));
        --y;
      }
      ans[len] = *--values.end();
    }
  }
  for (int k = 0; k < n; ++k) {
    cout << ans[n - k] << ' ';
  }
  cout << '\n';
}
