#include <bits/stdc++.h>
int main() {
  size_t n;
  std::cin >> n;
  std::vector<size_t> a(n);
  for (auto&& e : a) {
    std::cin >> e;
  }
  auto tmp = a;
  std::sort(a.begin(), a.end());
  auto max = tmp.at(tmp.size() - 1);
  auto max_1 = tmp.at(tmp.size() - 2);
  for (const auto& e : a) {
    if (e == max) {
      std::cout << max_1 << std::endl;
    } else {
      std::cout << max << std::endl;
    }
  }
  return 0;
}
