#include <bits/stdc++.h>
using namespace std;
template <typename T>
T &chmin(T &a, const T &b) {
  return a = min(a, b);
}
template <typename T>
T &chmax(T &a, const T &b) {
  return a = max(a, b);
}
const long long INF = 1e+18;
const double EPS = 1e-9;
const long long MOD = 1000000007;
const long long dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
long long n, lma[200010], rma[200010], a[200010];
signed main() {
  cin >> n;
  lma[0] = 0;
  rma[n] = 0;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    lma[i + 1] = max(lma[i], a[i]);
  }
  for (long long i = n - 1; i >= 0; i--) {
    rma[i] = max(rma[i + 1], a[i]);
  }
  for (long long i = 0; i < n; i++) {
    cout << max(lma[i], rma[i + 1]);
  }
}
