#include <bits/stdc++.h>
using namespace std;
int compare(const void* a, const void* b) {
  const int* x = (int*)a;
  const int* y = (int*)b;
  if (*x > *y)
    return 1;
  else if (*x < *y)
    return -1;
  return 0;
}
int main() {
  long long int n;
  cin >> n;
  long long int a[n + 1];
  for (long long int i = 1; i <= n; i++) cin >> a[i];
  a[0] = -1;
  qsort(a, n + 1, sizeof(int), compare);
  for (long long int i = 1; i < n; i++) {
    cout << a[n] << endl;
  }
  cout << a[n - 1] << endl;
}
