#include <bits/stdc++.h>
using namespace std;
void base() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
int32_t main() {
  base();
  long long int q;
  cin >> q;
  long long int arr[q];
  long long int Sort[q];
  for (long long int i = 0; i < q; i++) {
    cin >> arr[i];
    Sort[i] = arr[i];
  }
  sort(Sort, Sort + q);
  for (long long int i = 0; i < q; i++) {
    if (arr[i] == Sort[q - 1]) {
      if (q == 1)
        cout << arr[i] << "\n";
      else
        cout << Sort[q - 2] << "\n";
    } else
      cout << Sort[q - 1] << "\n";
  }
  return 0;
}
