#include <bits/stdc++.h>
using namespace std;
int a[10000000];
bool cmpjiang(int a, int b) { return a > b; }
bool cmpsheng(int a, int b) { return a < b; }
int main() {
  int n, sum = 1 - pow(2, 31), tot = pow(2, 31) - 1;
  cin >> n;
  bool s = 0, t = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sum = max(sum, a[i]);
    tot = min(tot, a[i]);
  }
  sort(a + 1, a + n + 1);
  cout << sum << " ";
  for (int i = 1; i <= n; i++) {
    if (s == 0 && a[i] == sum) {
      s = 1;
      continue;
    }
    if (t == 0 && a[i] == tot) {
      t = 1;
      continue;
    }
    cout << a[i] << " ";
  }
  cout << tot << endl;
  return 0;
}
