#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> list(N);
  for (int i = 0; i < N; i++) {
    cin >> list.at(i);
  }
  for (int j = 0; j < N; j++) {
    int L = list.at(j);
    sort(list.begin(), list.end());
    if (L == list.at(N - 1) && list.at(N - 2) == L) cout << L << endl;
    if (L < list.at(N - 1)) cout << list.at(N - 1) << endl;
    if (L == list.at(N - 1) && list.at(N - 2) != L)
      cout << list.at(N - 2) << endl;
  }
}
