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