#include <bits/stdc++.h>
int main() {
  long n;
  std::cin >> n;
  long a[n];
  for (long i = (0); i < (n); i++) std::cin >> a[i];
  long atmax = 0;
  long atmax2 = 0;
  long max = 0;
  for (long i = (0); i < (n); i++)
    if (max < a[i]) {
      max = a[i];
      atmax2 = atmax;
      atmax = i;
    }
  for (long i = (0); i < (n); i++)
    if (i != atmax)
      std::cout << a[atmax];
    else
      std::cout << a[atmax2];
  return 0;
}
