#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int t = 0; t < N; t++) {
    cin >> A.at(t);
  }
  int max = 0;
  for (int t = 0; t < N; t++) {
    if (A.at(t) > max) {
      max = A.at(t);
    }
  }
  for (int t = 0; t < N; t++) {
    if (A.at(t) != max) {
      cout << max << endl;
    } else {
      int submax = 0;
      for (int i = 0; i < N; i++) {
        if (i != t && A.at(i) > submax) {
          submax = A.at(i);
        }
      }
      cout << submax << endl;
    }
  }
}
