#include <bits/stdc++.h>
using namespace std;
int l[10086];
int main() {
  int n;
  cin >> n;
  for (int a = 0; a < n; a++) cin >> l[a];
  sort(l, l + n);
  cout << l[n - 1] << " ";
  for (int b = 1; b < n - 1; b++) cout << l[b] << " ";
  cout << l[0] << endl;
  return 0;
}
