#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n;
  int a[20005], esc[20005], ans[20005];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    esc[i] = a[i];
  }
  sort(esc, esc + n, greater<int>());
  for (int i = 0; i < n; i++) {
    if (a[i] == esc[0])
      ans[i] = esc[1];
    else if (a[i] != esc[0])
      ans[i] = esc[0];
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}
