#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i;
  scanf("%d", &n);
  vector<int> no;
  no.resize(n);
  for (i = 0; i < n; i++) scanf("%d", &no[i]);
  sort(no.begin(), no.end());
  printf("%d ", no[n - 1]);
  for (i = 1; i < n - 1; i++) printf("%d ", no[i]);
  printf("%d\n", no[0]);
}
