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