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