#include <bits/stdc++.h>
struct greater {
  template <class T>
  bool operator()(T const& a, T const& b) const {
    return a > b;
  }
};
int main() {
  int n;
  std::cin >> n;
  std::vector<int> data;
  for (int i = 0; i < n; i++) {
    int a = 0;
    std::cin >> a;
    data.push_back(a);
  }
  std::sort(data.begin(), data.end(), greater());
  for (int i = 0; i < n; i++) {
    int target = data.at(i);
    int first = data.at(0);
    if (target == first)
      std::cout << data.at(1);
    else
      std::cout << first;
  }
  return 0;
}
