#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (~scanf("%d", &n)) {
    int z[200005] = {0}, y[200005] = {0};
    for (int i = 0; i < n; i++) scanf("%d", &z[i]);
    int u = 0;
    sort(z, z + n);
    if (n <= 3) {
      if (n == 2) {
        y[u++] = z[n - 1];
        y[u++] = z[n - 2];
      } else {
        y[u++] = z[n - 1];
        y[u++] = z[n - 2];
        y[u++] = z[n - 1];
      }
    } else {
      for (int i = 0; i < n - 1; i++) {
        y[u++] = z[n - 1];
      }
      y[u++] = z[n - 2];
    }
    for (int i = 0; i < u; i++) printf("%d\n", y[i]);
  }
}
