#include <bits/stdc++.h>
int main() {
  int N;
  scanf("%d", &N);
  int A[N];
  for (int i = 0; i < N; i++) {
    scanf("%d", &A[i]);
  }
  int max_1 = 0;
  int max_2 = 0;
  for (int i = 0; i < N; i++) {
    if (A[i] > max_1) {
      max_2 = max_1;
      max_1 = A[i];
    }
    if (max_2 < A[i] && A[i] < max_1) max_2 = A[i];
  }
  int x = 0;
  for (int i = 0; i < N; i++) {
    if (A[i] == max_1) x++;
  }
  if (x = 1) {
    for (int i = 0; i < N; i++) {
      if (A[i] == max_1)
        printf("%d", max_2);
      else
        printf("%d", max_1);
    }
  }
  if (x >= 2) {
    for (int i = 0; i < N; i++) {
      printf("%d", max_1);
    }
  }
  return 0;
}
