#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
int n, a[N], pre[N], suf[N];
char ans[N];
struct Fenwick {
  int n, c[N];
  void init(int _n) {
    n = _n;
    memset(c, 0, sizeof(c[0]) * (n + 1));
  }
  void upd(int i, int v) {
    while (i <= n) {
      c[i] = max(c[i], v);
      i += i & -i;
    }
  }
  int qry(int i) {
    int r = 0;
    while (i > 0) {
      r = max(r, c[i]);
      i -= i & -i;
    }
    return r;
  }
} fw;
void solve(int f[]) {
  fw.init(*max_element(a, a + n));
  for (int i = (0); i < (n); ++i) {
    f[i] = fw.qry(a[i] - 1) + 1;
    fw.upd(a[i], f[i]);
  }
}
map<pair<int, int>, int> R;
int main() {
  scanf("%d", &n);
  for (int i = (0); i < (n); ++i) scanf("%d", a + i);
  solve(pre);
  reverse(a, a + n);
  int L = *max_element(a, a + n);
  for (int i = (0); i < (n); ++i) a[i] = L - a[i] + 1;
  solve(suf);
  reverse(suf, suf + n);
  L = *max_element(pre, pre + n);
  for (int i = (0); i < (n); ++i)
    if (pre[i] + suf[i] - 1 == L) {
      ++R[make_pair(pre[i], suf[i])];
    } else {
      ans[i] = '1';
    }
  for (int i = (0); i < (n); ++i)
    if (pre[i] + suf[i] - 1 == L)
      ans[i] = '2' + (R[make_pair(pre[i], suf[i])] == 1);
  ans[n] = '\0';
  puts(ans);
  return 0;
}
