#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  int M = 0;
  cin >> N;
  vector<int> vec(N);
  for (int X = 0; X < N; X++) {
    cin >> vec.at(X);
  }
  sort(vec.begin(), vec.end());
  for (int X = 0; X < N; X++) {
    if (X == N - 1) {
      cout << vec.at(N - 2) << endl;
    } else {
      cout << vec.at(N - 1) << endl;
    }
  }
}
