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

signed main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int& x : A) cin >> x;
    vector<int> dsc = A;
    sort(dsc.rbegin(), dsc.rend());
    for (int i = 0; i < N; i++) {
        cout << (A[i] == dsc[0] ? dsc[1] : dsc[0]) << endl;
    }
}
