#include <bits/stdc++.h>
using namespace std;
int tree[1000000], ar[1000000], pr[1000000], keep[1000000], n, endhere[1000000],
    starthere[1000000], lis, ans[1000000];
void update(int node, int beg, int end, int i, int val) {
  if (i > end || i < beg) return;
  if (beg >= i && end <= i) {
    tree[node] = val;
    return;
  }
  int Left = node * 2;
  int Right = node * 2 + 1;
  int mid = (beg + end) / 2;
  update(Left, beg, mid, i, val);
  update(Right, mid + 1, end, i, val);
  tree[node] = max(tree[Left], tree[Right]);
}
int query(int node, int beg, int end, int i, int j) {
  if (i > end || j < beg) return 0;
  if (beg >= i && end <= j) return tree[node];
  int Left = node * 2;
  int Right = node * 2 + 1;
  int mid = (beg + end) / 2;
  int p1 = query(Left, beg, mid, i, j);
  int p2 = query(Right, mid + 1, end, i, j);
  return max(p1, p2);
}
int main() {
  int a, s, d, f, g, h, j, k, l;
  lis = 0;
  scanf("%d", &n);
  for (a = 1; a <= n; a++) {
    scanf("%d", &ar[a]);
    pr[a] = 100000 - ar[a] + 1;
  }
  memset(tree, 0, sizeof(tree));
  for (a = 1; a <= n; a++) {
    s = query(1, 1, 100000, 1, ar[a] - 1);
    update(1, 1, 100000, ar[a], s + 1);
    endhere[a] = s + 1;
    lis = max(lis, s + 1);
  }
  reverse(pr + 1, pr + 1 + n);
  memset(tree, 0, sizeof(tree));
  for (a = 1; a <= n; a++) {
    s = query(1, 1, 100000, 1, pr[a] - 1);
    update(1, 1, 100000, pr[a], s + 1);
    starthere[n - a + 1] = s + 1;
  }
  for (a = 1; a <= n; a++) {
    if (starthere[a] + endhere[a] - 1 != lis)
      ans[a] = 1;
    else {
      keep[endhere[a]]++;
    }
  }
  for (a = 1; a <= n; a++) {
    if (ans[a] == 0) {
      if (keep[endhere[a]] == 1)
        ans[a] = 3;
      else
        ans[a] = 2;
    }
  }
  for (a = 1; a <= n; a++) {
    cout << ans[a];
  }
  cout << endl;
}
