#include <bits/stdc++.h>
using namespace std;
int n, v[100005 + 5], pd[100005 + 5], mx, sol[100005 + 5], mxval[100005 + 5];
int aint[4 * 100005 + 20], uz[100005 + 5];
void query_aint(int nod, int l, int r, int lq, int rq);
void update_aint(int nod, int l, int r, int pos, int val);
int main() {
  int i;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> v[i];
    mx = 0;
    if (v[i] > 1) query_aint(1, 1, 100005, 1, v[i] - 1);
    pd[i] = mx + 1;
    update_aint(1, 1, 100005, v[i], pd[i]);
  }
  mx = 0;
  for (i = 1; i <= n; i++)
    if (pd[i] > mx) mx = pd[i];
  for (i = n; i >= 1; i--) {
    if (pd[i] == mx || mxval[pd[i] + 1] > v[i]) {
      sol[i] = 2;
      if (v[i] > mxval[pd[i]]) mxval[pd[i]] = v[i];
      uz[pd[i]]++;
    } else
      sol[i] = 1;
  }
  for (i = 1; i <= n; i++) {
    if (sol[i] == 2 && uz[pd[i]] == 1) sol[i]++;
    cout << sol[i];
  }
  return 0;
}
void query_aint(int nod, int l, int r, int lq, int rq) {
  if (lq <= l && r <= rq) {
    if (aint[nod] >= mx) mx = aint[nod];
    return;
  }
  int mid = (l + r) >> 1;
  if (mid >= lq) query_aint(2 * nod, l, mid, lq, rq);
  if (mid + 1 <= rq) query_aint(2 * nod + 1, mid + 1, r, lq, rq);
}
void update_aint(int nod, int l, int r, int pos, int val) {
  if (l == r) {
    if (val > aint[nod]) aint[nod] = val;
    return;
  }
  int mid = (l + r) >> 1;
  if (pos <= mid)
    update_aint(2 * nod, l, mid, pos, val);
  else
    update_aint(2 * nod + 1, mid + 1, r, pos, val);
  aint[nod] = ((aint[2 * nod]) > (aint[2 * nod + 1])) ? (aint[2 * nod])
                                                      : (aint[2 * nod + 1]);
}
