#include <bits/stdc++.h>
using namespace std;
using ull = int;
int main() {
  ull n;
  cin >> n;
  ;
  vector<ull> a(n);
  for (ull i = 0, i_len = (n); i < i_len; ++i) {
    cin >> a[i];
  };
  ull max1 = 0;
  for (ull i = 0, i_len = (n); i < i_len; ++i) {
    max1 = max(max1, a[i]);
  }
  for (ull i = 0, i_len = (n); i < i_len; ++i) {
    if (a[i] < max1) {
      cout << max1 << "\n";
    } else {
      ull max2 = 0;
      for (ull j = 0, j_len = (n); j < j_len; ++j) {
        if (i != j) max2 = max(max2, a[j]);
      }
      cout << max2 << "\n";
    }
  }
}
