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