#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, k, n, a;
  vector<int> x;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a;
    x.push_back(a);
  }
  sort(x.begin(), x.end());
  cout << x[n - 1] << " ";
  for (i = 1; i < n - 1; i++) {
    cout << x[i] << " ";
  }
  cout << x[0];
  return 0;
}
