#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N;
  cin >> N;
  vector<long long> A(N);
  vector<long long> Aorg(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    Aorg[i] = A[i];
  }
  sort(A.rbegin(), A.rend());
  for (int i = 0; i < N; i++) {
    if (A[i] == Aorg[i]) {
      cout << A[1] << "\n";
    } else {
      cout << A[0] << "\n";
    }
  }
  return 0;
}
