#include <bits/stdc++.h>
using namespace std;
template <class T>
void out(T A[], int n) {
  for (int i = 0; i < n; i++) cout << A[i] << " ";
  cout << endl;
}
template <class T>
void out(vector<T> A, int n = -1) {
  if (n == -1) n = A.size();
  for (int i = 0; i < n; i++) cout << A[i] << " ";
  cout << endl;
}
const int MAXN = 99999;
const int MAXM = 9999999;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const double EPS = 1e-11;
int n, a[105];
int main() {
  int i;
  cin >> n;
  for (i = 0; i < n; i++) cin >> a[i];
  for (i = 1; i < n; i++)
    if (a[i] > a[0]) {
      int tmp = a[0];
      a[0] = a[i];
      a[i] = tmp;
    }
  for (i = 0; i < n - 1; i++)
    if (a[i] < a[n - 1]) {
      int tmp = a[n - 1];
      a[n - 1] = a[i];
      a[i] = tmp;
    }
  sort(a + 1, a + n - 1);
  for (i = 0; i < n; i++) cout << a[i] << ' ';
  cout << endl;
  return 0;
}
