#include <bits/stdc++.h>
using namespace std;
struct data {
  int len, cnt;
  data(int _len = 0, int _cnt = 0) : len(_len), cnt(_cnt) {}
};
const int base = (int)1e9 + 7;
const int N = 1e5 + 5;
int n, a[N];
data tree[4 * N], emp;
data dp1[N], dp2[N];
void modify(data &x, const data &y) {
  if (x.len < y.len)
    x = y;
  else if (x.len == y.len)
    x.cnt = (x.cnt + y.cnt) % base;
}
void update(int k, int l, int r, int p, data val) {
  if (l > r || l > p || r < p) return;
  if (l == r && l == p) {
    modify(tree[k], val);
    return;
  }
  int mid = (l + r) >> 1;
  update(k << 1, l, mid, p, val);
  update(k << 1 | 1, mid + 1, r, p, val);
  tree[k].len = 0, tree[k].cnt = 0;
  modify(tree[k], tree[k << 1]);
  modify(tree[k], tree[k << 1 | 1]);
}
data query(int k, int l, int r, int L, int R) {
  if (l > r || l > R || r < L) return emp;
  if (L <= l && r <= R) return tree[k];
  int mid = (l + r) >> 1;
  data ans = query(k << 1, l, mid, L, R);
  data tmp = query(k << 1 | 1, mid + 1, r, L, R);
  modify(ans, tmp);
  return ans;
}
int main() {
  scanf("%d", &n);
  for (int i = (1); i <= (n); ++i) scanf("%d", &a[i]);
  for (int i = (1); i <= (n); ++i) {
    dp1[i] = query(1, 1, N - 5, 1, a[i] - 1);
    if (!dp1[i].len)
      dp1[i].len = dp1[i].cnt = 1;
    else
      ++dp1[i].len;
    update(1, 1, N - 5, a[i], dp1[i]);
  }
  long long total = tree[1].cnt;
  memset(tree, 0, sizeof(tree));
  for (int i = (n); i >= (1); --i) {
    dp2[i] = query(1, 1, N - 5, a[i] + 1, N - 5);
    if (!dp2[i].len)
      dp2[i].len = dp2[i].cnt = 1;
    else
      ++dp2[i].len;
    update(1, 1, N - 5, a[i], dp2[i]);
  }
  for (int i = (1); i <= (n); ++i) {
    if (dp1[i].len + dp2[i].len - 1 != tree[1].len)
      printf("1");
    else if (dp1[i].len + dp2[i].len - 1 == tree[1].len) {
      if (1LL * dp1[i].cnt * dp2[i].cnt % base == total)
        printf("3");
      else
        printf("2");
    }
  }
  return 0;
}
