#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int A[200020];
  int B[200020];
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
    B[i] = A[i];
  }
  sort(B + 1, B + N + 1);
  for (int i = 1; i <= N; i++) {
    if (B[N] == B[N - 1])
      cout << B[N];
    else if (A[i] == B[N])
      cout << B[N - 1];
    else
      cout << B[N];
    cout << "¥n";
  }
}
