#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 50;
int n, a[maxn], p[maxn], s[maxn], t[maxn];
vector<int> v;
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  v.push_back(a[0]);
  for (int i = 1; i < n; ++i) {
    if (a[i] > v.back()) {
      p[i] = v.size();
      v.push_back(a[i]);
      continue;
    }
    int j = lower_bound(v.begin(), v.end(), a[i]) - v.begin();
    if (j != n) {
      v[j] = a[i];
      p[i] = j;
    }
  }
  int ans = v.size();
  v.clear();
  v.push_back(a[n - 1]);
  for (int i = n - 2; i >= 0; --i) {
    if (a[i] < v.back()) {
      s[i] = v.size();
      v.push_back(a[i]);
      continue;
    }
    int l = -1, r = v.size(), m;
    while (l < r - 1) {
      m = (l + r) >> 1;
      if (v[m] <= a[i])
        r = m;
      else
        l = m;
    }
    v[r] = a[i];
    s[i] = r;
  }
  for (int i = 0; i < n; i++) {
    if (p[i] + 1 + s[i] == ans) t[p[i]]++;
  }
  for (int i = 0; i < n; i++) {
    if (p[i] + 1 + s[i] == ans) {
      if (t[p[i]] == 1)
        cout << 3;
      else
        cout << 2;
    } else
      cout << 1;
  }
  cout << endl;
  return 0;
}
