#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a;
  int temp;
  int max_1 = 0;
  int max_2 = 0;
  int max_num;
  for (int i = 0; i < n; i++) {
    cin >> temp;
    a.push_back(temp);
    if (max_1 <= temp) {
      max_1 = temp;
      max_num = i;
    }
    if (max_2 <= temp && temp <= max_1) {
      max_2 = temp;
    }
  }
  for (int i = 0; i < n; i++) {
    if (i != max_num)
      cout << max_1;
    else
      cout << max_2;
  }
  return 0;
}
