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