#include <bits/stdc++.h>
using namespace std;

int main() {
   int N;
  cin >> N;
  vector<int> A(N), a(N);
  for (int i = 0; i < N; ++i) cin >> A.at(i);
  a = A;
  sort(a.begin(), a.end());
  
  for (int i = 0; i < N; ++i) {
    if(A.at(i) == a.at(N-1)) cout << a.at(N-2) << endl;
    else cout << a.at(N-1) << endl;
  }
}