#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N;
  cin >> N;
  vector<long long> A(N);
  vector<long long> B(N);
  for (long long i = (0); i < (N); i++) {
    cin >> A[i];
    B[i] = A[i];
  }
  sort(A.begin(), A.end());
  for (long long i = (0); i < (N); i++) {
    sort(A.begin(), A.end());
    if (A[N - 1] == B[i]) {
      cout << A[N - 2] << endl;
    } else {
      cout << A[N - 1] << endl;
    }
  }
}
