#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  vector<int> A(N);
  for (auto &a : A) cin >> a;
  auto B = A;
  sort(A.begin(), A.end(), greater<int>());
  for (auto b : B) {
    if (b != A[0]) {
      cout << A[0] << endl;
    } else {
      cout << A[1] << endl;
    }
  }
  return 0;
}
