#include <bits/stdc++.h>
using namespace std;
vector<long> vi;
int main() {
  std::ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  for (int i = 0; i < (int)(n); ++i) {
    long x;
    cin >> x;
    vi.push_back(x);
  }
  sort((vi).begin(), (vi).end());
  cout << vi[n - 1];
  for (int i = 1; i <= (int)(n - 2); ++i) {
    cout << " " << vi[i];
  }
  cout << " " << vi[0];
  return 0;
}
