#include <bits/stdc++.h>
using namespace std;
int dp[100010];
int ans;
int a[100010];
int len[100010];
vector<int> pos[100010];
set<int> good[100010];
bool maybe[100010];
int resu[100010];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    int l, r;
    l = 0, r = ans;
    while (l < r) {
      int mid = (l + r + 1) >> 1;
      if (dp[mid] >= a[i]) {
        r = mid - 1;
      } else {
        l = mid;
      }
    }
    len[i] = l + 1;
    if (l + 1 > ans) {
      ans = l + 1;
      dp[ans] = a[i];
    } else {
      dp[len[i]] = min(dp[len[i]], a[i]);
    }
  }
  for (int i = 1; i <= n; i++) {
    pos[len[i]].push_back(i);
  }
  for (int i = n; i >= 1; i--) {
    if (len[i] == ans) {
      maybe[i] = 1;
    } else {
      if (upper_bound(good[len[i] + 1].begin(), good[len[i] + 1].end(), a[i]) !=
          good[len[i] + 1].end()) {
        maybe[i] = 1;
      }
    }
    if (maybe[i]) {
      good[len[i]].insert(a[i]);
    }
  }
  for (int i = ans; i >= 1; i--) {
    int cnt = 0;
    int who;
    for (int j = 0; j < pos[i].size(); j++) {
      if (maybe[pos[i][j]]) {
        resu[pos[i][j]] = 2;
        who = pos[i][j];
        cnt++;
      } else {
        resu[pos[i][j]] = 1;
      }
    }
    if (cnt == 1) {
      resu[who] = 3;
    }
  }
  for (int i = 1; i <= n; i++) {
    printf("%d", resu[i]);
  }
  puts("");
  return 0;
}
