#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  vector<int> a;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
  int max = *std::max_element(a.begin(), a.end());
  for (int i = 0; i < n; i++) {
    if (a[i] < max) {
      cout << max << endl;
    } else {
      a[i] = INT_MIN;
      cout << *std::max_element(a.begin(), a.end()) << endl;
    }
  }
  return 0;
}
