#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
constexpr int maxn = 1e5 + 10;
vector<int> topo;
vector<vector<pii>> pilha;
int ans[maxn];
int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (auto& it : a) scanf("%d", &it);
  for (int i = 0; i < n; i++) {
    auto it = lower_bound((topo).begin(), (topo).end(), a[i]);
    if (it == topo.end())
      topo.push_back(a[i]), pilha.push_back({{a[i], i}});
    else {
      int pos = (int)(it - topo.begin());
      topo[pos] = a[i];
      pilha[pos].push_back({a[i], i});
    }
  }
  vector<pii> valid = pilha.back();
  if ((int)((valid).size()) > 1)
    for (auto it : valid) ans[it.second] = 2;
  else
    ans[valid[0].second] = 3;
  for (int i = (int)((pilha).size()) - 2; i >= 0; i--) {
    assert((int)((valid).size()));
    sort((valid).begin(), (valid).end());
    vector<int> suf((int)((valid).size())), comp((int)((valid).size()));
    suf.back() = valid.back().second;
    for (int pos = (int)((valid).size()) - 2; pos >= 0; pos--)
      suf[pos] = max(suf[pos + 1], valid[pos].second);
    for (int j = 0; j < (int)((valid).size()); j++) comp[j] = valid[j].first;
    valid.clear();
    for (int j = 0; j < (int)((pilha[i]).size()); j++) {
      auto it = upper_bound((comp).begin(), (comp).end(), pilha[i][j].first);
      if (it == comp.end())
        ans[pilha[i][j].second] = 1;
      else {
        int pos = (int)(it - comp.begin());
        if (suf[pos] < pilha[i][j].second)
          ans[pilha[i][j].second] = 1;
        else
          valid.push_back(pilha[i][j]);
      }
    }
    if ((int)((valid).size()) > 1)
      for (auto it : valid) ans[it.second] = 2;
    else
      ans[valid[0].second] = 3;
  }
  for (int i = 0; i < n; i++) printf("%d", ans[i]);
  printf("\n");
}
