#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  int a[n];
  int MAX = -100;
  int MMAX = -100;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    MAX = max(MAX, a[i]);
  }
  for (int i = 0; i < n; i++) {
    if (a[i] != MAX)
      cout << MAX << endl;
    else {
      for (int j = 0; j < n; j++) {
        if (j != i) {
          MMAX = max(MMAX, a[j]);
        }
      }
      cout << MMAX << endl;
    }
  }
  return 0;
}
