#include <bits/stdc++.h>
using namespace std;
bool cmp(const vector<pair<long long, long long> > &v,
         const vector<pair<long long, long long> > &v2) {
  return v.back() < v2.back();
}
int main() {
  int ans[100005];
  memset(ans, 0, sizeof(ans));
  int n;
  scanf("%d", &n);
  vector<vector<pair<long long, long long> > > v;
  for (int i = 0; i < n; i++) {
    long long a;
    scanf("%lld", &a);
    if (v.empty() || v.back().back().first < a) {
      vector<pair<long long, long long> > vv;
      vv.push_back(make_pair((a), (i)));
      v.push_back(vv);
    } else {
      vector<pair<long long, long long> > vv;
      vv.push_back(make_pair((a), (0)));
      auto it = lower_bound(v.begin(), v.end(), vv, cmp);
      it->push_back(make_pair((a), (i)));
    }
  }
  vector<pair<long long, long long> > temp = v.back();
  if (temp.size() == 1)
    ans[temp.back().second] = 3;
  else
    for (auto it : temp) ans[it.second] = 2;
  vector<pair<long long, long long> > temp2;
  v.pop_back();
  while (!v.empty()) {
    temp2.clear();
    vector<pair<long long, long long> > vv = v.back();
    v.pop_back();
    while (!temp.empty() && !vv.empty()) {
      while (!vv.empty() && vv.back().second > temp.back().second)
        vv.pop_back();
      while (!vv.empty() && vv.back().first < temp.back().first &&
             vv.back().second < temp.back().second) {
        temp2.push_back(vv.back());
        vv.pop_back();
      }
      temp.pop_back();
    }
    swap(temp, temp2);
    if (temp.size() == 1)
      ans[temp.back().second] = 3;
    else
      for (auto it : temp) ans[it.second] = 2;
    reverse(temp.begin(), temp.end());
  }
  for (int i = 0; i < n; i++) {
    if (ans[i] == 0)
      printf("1");
    else
      printf("%d", ans[i]);
  }
  printf("\n");
}
