#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast,no-stack-protector")
long long int gcd(long long int a, long long int b) {
  if (a < b) swap(a, b);
  return ((b == 0) ? a : gcd(b, a % b));
}
const long long int MAXN = 1e5 + 15, md = 1e9 + 7, inf = 1e18;
long long int tav(long long int n, long long int k) {
  long long int res = 1;
  while (k > 0) {
    if (k & 1) {
      res *= n;
      res %= md;
    }
    n *= n;
    n %= md;
    k >>= 1;
  }
  return res;
}
long long int dp[MAXN], pd[MAXN], cnt[MAXN];
vector<long long int> v, a;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  memset(cnt, 0, sizeof(cnt));
  long long int n, g = 0;
  cin >> n;
  a.resize(n);
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
  }
  v.assign(n, inf);
  for (long long int i = 0; i < n; i++) {
    long long int q = lower_bound(v.begin(), v.end(), a[i]) - v.begin();
    dp[i] = q + 1;
    v[q] = a[i];
    g = max(g, dp[i]);
  }
  v.clear();
  v.assign(n, inf);
  reverse(a.begin(), a.end());
  for (long long int i = 0; i < n; i++) {
    a[i] = -a[i];
  }
  for (long long int i = 0; i < n; i++) {
    long long int q = lower_bound(v.begin(), v.end(), a[i]) - v.begin();
    pd[n - i - 1] = q + 1;
    v[q] = a[i];
  }
  g++;
  for (long long int i = 0; i < n; i++) {
    long long int h = dp[i] + pd[i];
    if (h == g) {
      cnt[dp[i]]++;
    }
  }
  for (long long int i = 0; i < n; i++) {
    if (dp[i] + pd[i] != g) {
      cout << '1';
    } else {
      if (cnt[dp[i]] > 1) {
        cout << '2';
      } else {
        cout << '3';
        ;
      }
    }
  }
  cout << '\n';
  return 0;
}
