#include <bits/stdc++.h>
using namespace std;
vector<int> ed;
vector<int> ans;
vector<int> a;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    a.push_back(k);
  }
  a.push_back(999999);
  ed.push_back(1);
  ans.push_back(a[0]);
  for (int i = 1; i < a.size(); i++) {
    if (a[i] > *(ans.end() - 1)) {
      ans.push_back(a[i]);
      ed.push_back(ans.size());
    } else {
      vector<int>::iterator it = lower_bound(ans.begin(), ans.end(), a[i]);
      ed.push_back(it - ans.begin() + 1);
      *it = a[i];
    }
  }
  vector<bool> flag(a.size(), false);
  map<int, multiset<int> > elements;
  elements[ed.back()].insert(a.back());
  flag[a.size() - 1] = true;
  for (int i = a.size() - 1; i >= 0; i--) {
    int l = ed[i];
    map<int, multiset<int> >::iterator it = elements.find(l + 1);
    if (it == elements.end()) continue;
    multiset<int>& t = it->second;
    if (t.upper_bound(a[i]) != t.end()) {
      elements[l].insert(a[i]);
      flag[i] = true;
    }
  }
  for (int i = 0; i < a.size() - 1; i++) {
    if (!flag[i])
      cout << 1;
    else {
      if (elements[ed[i]].size() == 1)
        cout << 3;
      else
        cout << 2;
    }
  }
  return 0;
}
