#include <bits/stdc++.h>
using namespace std;
bool cmp(int a, int b) { return a < b; }
int main(int argc, const char* argv[]) {
  int n, a[1000];
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  sort(a, a + n, cmp);
  printf("%d ", a[n - 1]);
  for (int i = 1; i < n - 1; i++) printf("%d ", a[i]);
  printf("%d\n", a[0]);
  return 0;
}
