#include <bits/stdc++.h>
using namespace std;
int t[401010];
int mx, n;
int ans[401010];
int a[401010];
void upd(int pos, int x, int v = 1, int tl = 1, int tr = 100001) {
  if (tl == tr) {
    t[v] = max(t[v], x);
    return;
  }
  int tm = (tl + tr) / 2;
  if (pos <= tm)
    upd(pos, x, v * 2, tl, tm);
  else
    upd(pos, x, v * 2 + 1, tm + 1, tr);
  t[v] = max(t[v * 2], t[v * 2 + 1]);
}
int get(int l, int r, int v = 1, int tl = 1, int tr = 100001) {
  if (tl >= l && tr <= r) return t[v];
  if (l > tr || tl > r) return 0;
  int tm = (tl + tr) / 2;
  int x = get(l, r, v * 2, tl, tm);
  int y = get(l, r, v * 2 + 1, tm + 1, tr);
  return max(x, y);
}
int pre[401010];
int suf[401010];
int u[401010];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    pre[i] = get(1, a[i] - 1) + 1;
    upd(a[i], pre[i]);
    mx = max(pre[i], mx);
  }
  memset(t, 0, sizeof t);
  for (int i = n; i > 0; i--) {
    suf[i] = get(a[i] + 1, 100001) + 1;
    upd(a[i], suf[i]);
  }
  for (int i = 1; i <= n; i++) {
    if (pre[i] + suf[i] - 1 != mx) {
      ans[i] = 1;
      continue;
    }
    u[pre[i]]++;
  }
  for (int i = 1; i <= n; i++) {
    if (pre[i] + suf[i] - 1 == mx) ans[i] = (u[pre[i]] == 1 ? 3 : 2);
    cout << ans[i];
  }
}
