#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int inf = 1e5 + 5;
int a[N], f[N], b[N], P[N];
vector<int> occur[N];
int ans[N];
int n, sz;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  sz = 1;
  b[0] = a[0];
  f[0] = 0;
  for (int i = 1; i < n; i++) {
    int cur = lower_bound(b, b + sz, a[i]) - b;
    b[cur] = a[i];
    if (cur == sz) sz++;
    f[i] = cur;
  }
  for (int i = 0; i < sz; i++) {
    occur[i].clear();
    P[i] = -1;
  }
  P[sz] = inf;
  for (int i = n - 1; i >= 0; i--) {
    if (P[f[i] + 1] > a[i]) {
      occur[f[i]].push_back(i);
      P[f[i]] = max(P[f[i]], a[i]);
    } else
      ans[i] = 1;
  }
  for (int i = 0; i < sz; i++) {
    int total = (int)occur[i].size();
    if (total == 1) {
      ans[occur[i][0]] = 3;
    } else
      for (int j = 0; j < total; j++) ans[occur[i][j]] = 2;
  }
  for (int i = 0; i < n; i++) cout << ans[i];
  cout << "\n";
}
