#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  vector<int> ar(n);
  for (int i = 0; i < n; i++) {
    cin >> ar[i];
  }
  vector<int> car = ar;
  sort(car.begin(), car.end());
  reverse(car.begin(), car.end());
  for (int i = 0; i < n; i++) {
    if (ar[i] == car[0])
      cout << car[1] << "\n";
    else
      cout << car[0] << "\n";
  }
  return 0;
}
