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