#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  vector<int> a(n);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int max;
  for (int i = 0; i < n; i++) {
    max = 0;
    for (int ii = 0; ii < n; ii++) {
      if (ii != i) {
        max = ((max < a[ii]) ? a[ii] : max);
      }
    }
    cout << max << endl;
  }
  return 0;
}
