#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < (int)(n); i++) cin >> a.at(i);
  sort(a.begin(), a.end());
  for (int i = 0; i < (int)(n); i++) {
    if (a.at(i) == a.at(n - 1))
      cout << a.at(n - 2) << endl;
    else
      cout << a.at(n - 1) << endl;
  }
  return 0;
}
