#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, d;
  cin >> n;
  int *a = new int[n];
  int ma = -1;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    ma = max(ma, a[i]);
  }
  for (int i = 0; i < n; i++) {
    if (a[i] != ma) {
      cout << ma << endl;
    } else {
      int m = -1;
      for (int j = 0; j < n; j++) {
        if (j != i) m = max(m, a[j]);
      }
      cout << m << endl;
    }
  }
}
