#include <bits/stdc++.h>
using namespace std;
bool great(long long a, long long b) { return a > b; }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  vector<long long> v;
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    long long x;
    cin >> x;
    v.push_back(x);
  }
  sort(v.begin(), v.end(), great);
  sort(v.begin() + 1, v.end() - 1);
  for (auto xx : v) {
    cout << xx << " ";
  }
  cout << endl;
  return 0;
}
