#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  int A[N];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A, A + N);
  reverse(A, A + N);
  int a = A[0];
  int b = A[1];
  for (int i = 0; i < N; i++) {
    if (A[i] == a) {
      cout << b << endl;
    } else {
      cout << a << endl;
    }
  }
}
