#include <bits/stdc++.h>
using namespace std;
ifstream f("2.in");
int main() {
  long long N;
  f >> N;
  vector<long long> A(N), B(N);
  for (int i = 0; i < N; i++) {
    f >> A[i];
    B[i] = A[i];
  }
  sort(B.begin(), B.end());
  for (int i = 0; i < N; i++) {
    if (A[i] == B[N - 1])
      cout << B[N - 2] << '\n';
    else
      cout << B[N - 1] << '\n';
  }
  return 0;
}
