#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
int a[100005], v[100005], p[100005], b[100005], cnt[100005], mx[100005];
int main() {
  int T, i, j, ca = 0, m, k, n;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  k = 0;
  b[k++] = 0;
  p[0] = 0;
  for (i = 1; i < n; i++) {
    int l = 0, r = k - 1;
    while (l <= r) {
      m = (l + r) >> 1;
      if (a[b[m]] < a[i])
        l = m + 1;
      else
        r = m - 1;
    }
    b[r + 1] = i;
    p[i] = r + 1;
    if (r + 1 >= k) k++;
  }
  for (i = n - 1; i >= 0; i--) {
    if (p[i] < k - 1 && a[i] >= mx[p[i] + 1]) v[i] = 1;
    if (v[i] == 0) mx[p[i]] = max(mx[p[i]], a[i]), cnt[p[i]]++;
  }
  for (i = 0; i < n; i++) {
    if (v[i] == 1)
      printf("1");
    else if (cnt[p[i]] == 1)
      printf("3");
    else
      printf("2");
  }
  puts("");
  return 0;
}
