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

int main() {
  int N;
  cin >> N;
  vector<int> A(N), B;
  for (int i = 0; i < N; i++) cin >> A.at(i);

  B = A;
  sort(B.rbegin(), B.rend());

  for (int i = 0; i < N; i++) {
    if (A.at(i) == B.at(0)) cout << B.at(1) << "\n";
    else cout << B.at(0) << "\n";
  }
}