#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll N;
  cin >> N;
  vector<ll> A(N), s(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
    s[i] = A[i];
  }
  sort(s.begin(), s.end(), greater<ll>());
  unique(s.begin(), s.end());
  ll max = 0, ans = 0;
  for (int i = 0; i < N; ++i) {
    if (s[0] == A[i])
      cout << s[1] << endl;
    else
      cout << s[0] << endl;
  }
  return 0;
}
