#include <bits/stdc++.h>
using namespace std;
pair<int, long long> merge(pair<int, long long> a, pair<int, long long> b) {
  if (a.first == b.first)
    return make_pair(a.first, (a.second + b.second) % 1000000007);
  return a.first > b.first ? a : b;
}
struct SegTree {
  pair<int, long long> tree[4 * 100001 + 5];
  void update(int no, int l, int r, int x, pair<int, long long> val) {
    if (l == r) {
      tree[no] = merge(tree[no], val);
      return;
    }
    int m = (l + r) / 2;
    if (x <= m)
      update(2 * no, l, m, x, val);
    else
      update(2 * no + 1, m + 1, r, x, val);
    tree[no] = merge(tree[2 * no], tree[2 * no + 1]);
  }
  pair<int, long long> query(int no, int l, int r, int a, int b) {
    if (a <= l && r <= b) return tree[no];
    int m = (l + r) / 2;
    pair<int, long long> ret = make_pair(0, 0);
    if (a <= m) ret = query(2 * no, l, m, a, b);
    if (m < b) ret = merge(ret, query(2 * no + 1, m + 1, r, a, b));
    return ret;
  }
};
int n, a[100001 + 5];
pair<int, long long> lisl[100001 + 5], lisr[100001 + 5];
SegTree tl, tr;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) {
    lisl[i] = merge(make_pair(0, 1), tl.query(1, 0, 100001, 0, a[i] - 1));
    lisl[i].first++;
    tl.update(1, 0, 100001, a[i], lisl[i]);
  }
  for (int i = n; i >= 1; i--) {
    lisr[i] = merge(make_pair(0, 1), tr.query(1, 0, 100001, a[i] + 1, 100001));
    lisr[i].first++;
    tr.update(1, 0, 100001, a[i], lisr[i]);
  }
  int len = tl.tree[1].first;
  long long qnt = tl.tree[1].second;
  for (int i = 1; i <= n; i++) {
    if (lisl[i].first + lisr[i].first - 1 < len)
      printf("1");
    else if (lisl[i].second * lisr[i].second % 1000000007 != qnt)
      printf("2");
    else
      printf("3");
  }
  puts("");
}
