#include <bits/stdc++.h>
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;
int main() {
  int n;
  std::cin >> n;
  vt<int> a(n);
  for (int i = 0; i < (int)n; i++) std::cin >> a[i];
  sort(a.begin(), a.end());
  for (int i = 0; i < (int)n; i++) {
    if (i != n - 1)
      std::cout << a[n - 1] << '\n';
    else
      std::cout << a[n - 2] << '\n';
  }
  return 0;
}
