#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  for (int i = 0; i < N; i++) {
    if (A[i] == A[N - 1]) {
      cout << A[N - 2] << endl;
    } else {
      cout << A[N - 1] << endl;
    }
  }
}
