#include <bits/stdc++.h>
using namespace std;
int n;
const int N = 1e5 + 5;
int prf[N], suf[N], f[N], a[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<int> vec;
  vector<int>::iterator it;
  for (int i = 0; i < n; i++) {
    it = lower_bound(vec.begin(), vec.end(), a[i]);
    prf[i] = 1 + it - vec.begin();
    if (it == vec.end())
      vec.push_back(a[i]);
    else
      *it = a[i];
  }
  int ls = vec.size();
  vec.clear();
  for (int i = n - 1; i >= 0; i--) {
    it = lower_bound(vec.begin(), vec.end(), -a[i]);
    suf[i] = 1 + it - vec.begin();
    if (it == vec.end())
      vec.push_back(-a[i]);
    else
      *it = -a[i];
  }
  for (int i = 0; i < n; i++) {
    if (prf[i] + suf[i] - 1 != ls) continue;
    f[prf[i]]++;
  }
  for (int i = 0; i < n; i++) {
    if (prf[i] + suf[i] - 1 != ls)
      cout << 1;
    else if (f[prf[i]] > 1)
      cout << 2;
    else
      cout << 3;
  }
  return 0;
}
