#include <bits/stdc++.h>
using namespace std;
double PI = 3.14159265358979;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  set<int> B(A.begin(), A.end());
  vector<int> C(B.begin(), B.end());
  int n = C.size();
  for (int i = 0; i < N; i++) {
    if (A[i] == C[n - 1] && n != 1) {
      cout << C[n - 2] << endl;
    } else {
      cout << C[n - 1] << endl;
    }
  }
}
