#include <bits/stdc++.h>
using namespace std;
long long n, x, y, k;
vector<long long> V;
long long sol[300010];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x;
    V.push_back(x);
  }
  for (int i = 0; i < n - 2; i++) {
    x = max(min(V[i], V[i + 2]), V[i + 1]);
    k = abs(n - (3 + i * 2));
    k = abs(k - 1);
    sol[k] = max(sol[k], x);
  }
  for (int i = 0; i < n - 1; i++) {
    x = min(V[i], V[i + 1]);
    k = abs(n - (2 + i * 2));
    k = abs(k - 1);
    sol[k] = max(sol[k], x);
  }
  for (int i = 2; i < n; i++) {
    sol[i] = max(sol[i], sol[i - 2]);
  }
  sort(V.begin(), V.end());
  for (int i = 0; i < n - 2; i++) {
    cout << sol[i] << " ";
  }
  cout << V.back();
  if (n > 1) cout << " " << V.back() << "\n";
}
