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