#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long fceil(long long a, long long b) {
  return (a % b == 0 ? a / b : a / b + 1);
}
int main() {
  int n, a[200007] = {}, l[200007] = {}, r[200007] = {};
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    l[i] = max(a[i], l[i - 1]);
    r[n - i + 1] = max(a[n - i + 1], r[n - i + 2]);
  }
  for (int i = 1; i <= n; i++) cout << max(l[i - 1], r[i + 1]);
  return 0;
}
