#include <bits/stdc++.h>
int main() {
  int n;
  std::cin >> n;
  std::vector<int> a(n);
  int i = 0;
  int max = 0;
  for (int i = 0; i < n; ++i) {
    std::cin >> a.at(i);
    max = std::max(max, a.at(i));
  }
  for (int i = 0; i < n; ++i) {
    int ans = max;
    if (a.at(i) == max) {
      a.at(i) = 0;
      ans = *std::max_element(a.begin(), a.end());
      a.at(i) = max;
    }
    std::cout << ans << std::endl;
  }
  return 0;
}
