#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[N];
data dp1[N], dp2[N];
void update(int idx, data val) {
  for (; idx < N; idx += idx & -idx)
    if (tree[idx].len < val.len)
      tree[idx] = val;
    else if (tree[idx].len == val.len)
      tree[idx].cnt = (tree[idx].cnt + val.cnt) % base;
}
data read(int idx) {
  data ans;
  for (; idx; idx -= idx & -idx)
    if (ans.len < tree[idx].len)
      ans = tree[idx];
    else if (ans.len == tree[idx].len)
      ans.cnt = (ans.cnt + tree[idx].cnt) % base;
  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] = read(a[i] - 1);
    if (!dp1[i].len)
      dp1[i].len = dp1[i].cnt = 1;
    else
      ++dp1[i].len;
    update(a[i], dp1[i]);
  }
  data total = read(N - 1);
  memset(tree, 0, sizeof(tree));
  for (int i = (n); i >= (1); --i) {
    dp2[i] = read((int)1e5 - a[i]);
    if (!dp2[i].len)
      dp2[i].len = dp2[i].cnt = 1;
    else
      ++dp2[i].len;
    update((int)1e5 - a[i] + 1, dp2[i]);
  }
  for (int i = (1); i <= (n); ++i) {
    if (dp1[i].len + dp2[i].len - 1 != total.len)
      printf("1");
    else if (dp1[i].len + dp2[i].len - 1 == total.len) {
      if (1LL * dp1[i].cnt * dp2[i].cnt % base != (long long)total.cnt)
        printf("2");
      else
        printf("3");
    }
  }
  return 0;
}
