#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int a[maxn], g[maxn], f[maxn], cnt[maxn];
int main() {
  ios::sync_with_stdio(false);
  vector<int> v;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    int p = lower_bound(v.begin(), v.end(), a[i]) - v.begin();
    if (v.size() == p)
      v.push_back(a[i]);
    else
      v[p] = a[i];
    g[i] = p;
  }
  int lis = v.size();
  for (int i = 0; i < n; i++) a[i] = -a[i];
  v.clear();
  for (int i = n; i--;) {
    int p = lower_bound(v.begin(), v.end(), a[i]) - v.begin();
    if (v.size() == p)
      v.push_back(a[i]);
    else
      v[p] = a[i];
    f[i] = p;
  }
  string o = "";
  for (int i = 0; i < n; i++)
    if (g[i] + f[i] + 1 == lis) cnt[g[i]]++;
  for (int i = 0; i < n; i++) {
    if (g[i] + f[i] + 1 != lis)
      o += "1";
    else {
      if (cnt[g[i]] == 1)
        o += "3";
      else
        o += "2";
    }
  }
  cout << o << endl;
}
