#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N;
  cin >> N;
  vector<long long> A(N);
  long long max = LLONG_MIN;
  for (long long i = 0; i < N; i++) {
    cin >> A[i];
    if (A[i] > max) {
      max = A[i];
    }
  }
  for (long long i = 0; i < N; ++i) {
    if (A[i] == max) {
      long long max_ = LLONG_MIN;
      for (long long j = 0; j < N; ++j) {
        if (j != i) {
          if (max_ < A[j]) {
            max_ = A[j];
          }
        }
      }
      cout << max_ << endl;
    } else {
      cout << max << endl;
    }
  }
  return 0;
}
