#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 7;
struct node {
  int l, r;
  int mid() { return (l + r) >> 1; }
  int val;
} t[maxn * 4];
int Beg[maxn], End[maxn], n, a[maxn];
int Lis;
int kind[maxn];
void build(int l, int r, int id) {
  t[id].val = 0;
  t[id].l = l;
  t[id].r = r;
  if (t[id].l == t[id].r) return;
  int m = t[id].mid();
  build(l, m, ((id) << 1));
  build(m + 1, r, (id << 1 | 1));
}
int query(int l, int r, int id) {
  if (l > r) return 0;
  if (l == t[id].l && r == t[id].r) return t[id].val;
  int m = t[id].mid();
  if (m >= r)
    return query(l, r, ((id) << 1));
  else if (m < l)
    return query(l, r, (id << 1 | 1));
  else
    return max(query(l, m, ((id) << 1)), query(m + 1, r, (id << 1 | 1)));
}
void update(int id, int pos, int add) {
  if (t[id].l == t[id].r && t[id].l == pos) {
    t[id].val = max(t[id].val, add);
    return;
  }
  int m = t[id].mid();
  if (pos <= m)
    update(((id) << 1), pos, add);
  else
    update((id << 1 | 1), pos, add);
  t[id].val = max(t[((id) << 1)].val, t[(id << 1 | 1)].val);
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  build(1, maxn - 5, 1);
  for (int i = 1; i <= n; i++) {
    int maxx = query(1, a[i] - 1, 1);
    Beg[i] = maxx + 1;
    Lis = max(Lis, Beg[i]);
    update(1, a[i], Beg[i]);
  }
  build(1, maxn - 5, 1);
  for (int i = n; i >= 1; i--) {
    int maxx = query(a[i] + 1, maxn - 5, 1);
    End[i] = maxx + 1;
    Lis = max(Lis, End[i]);
    update(1, a[i], End[i]);
  }
  build(1, maxn - 5, 1);
  for (int i = 1; i <= n; i++) {
    if (Beg[i] + End[i] - 1 < Lis)
      kind[i] = 1;
    else if (query(a[i], maxn - 5, 1) == Lis)
      kind[i] = 2;
    else
      kind[i] = 3;
    update(1, a[i], Beg[i] + End[i] - 1);
  }
  build(1, maxn - 5, 1);
  for (int i = n; i >= 1; i--) {
    if (kind[i] == 1) continue;
    if (query(1, a[i], 1) == Lis) kind[i] = 2;
    update(1, a[i], Beg[i] + End[i] - 1);
  }
  for (int i = 1; i <= n; i++) printf("%d", kind[i]);
  return 0;
}
