#include <bits/stdc++.h>
long long arr[100005];
using namespace std;
int main() {
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  ;
  int n;
  cin >> n;
  for (int i = 0; i < n; cin >> arr[i++])
    ;
  sort(arr, arr + n);
  cout << arr[n - 1] << " ";
  for (int i = 1; i < n - 1; i++) {
    cout << arr[i] << " ";
  }
  cout << arr[0];
}
