#include <bits/stdc++.h>
int main() {
  int n;
  std::cin >> n;
  int *arr = new int[n];
  for (int i = 0; i != n; ++i) std::cin >> arr[i];
  std::sort(arr, arr + n, std::greater<int>());
  std::sort(arr + 1, arr + n - 1);
  for (int i = 0; i != n; ++i) {
    std::cout << arr[i] << " ";
  }
  return 0;
}
