#include <bits/stdc++.h>
int num[100005], dp[100005], min[100005], fl[100005], nowmax[100005],
    nowmin[100005], mul[100005];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &num[i]);
  }
  dp[0] = 1;
  min[1] = num[0];
  int max = 1;
  for (int i = 1; i < n; i++) {
    int left = 1, right = max;
    while (left <= right) {
      int mid = (left + right) / 2;
      if (min[mid] < num[i])
        left = mid + 1;
      else
        right = mid - 1;
    }
    dp[i] = left;
    min[left] = num[i];
    if (left > max) max = left;
  }
  memset(fl, 0, sizeof(fl));
  memset(mul, 0, sizeof(mul));
  int nowcheck = max;
  for (int i = n - 1; i >= 0; i--) {
    if (dp[i] < nowcheck)
      fl[i] = 1;
    else if (dp[i] == nowcheck) {
      nowmax[nowcheck] = num[i];
      nowmin[nowcheck] = num[i];
      nowcheck--;
    } else {
      if (dp[i] < max && num[i] >= nowmax[dp[i] + 1])
        fl[i] = 1;
      else {
        mul[dp[i]] = 1;
        if (num[i] > nowmax[dp[i]])
          nowmax[dp[i]] = num[i];
        else if (num[i] < nowmin[dp[i]])
          nowmin[dp[i]] = num[i];
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (fl[i] == 1)
      printf("1");
    else if (mul[dp[i]])
      printf("2");
    else
      printf("3");
  }
  printf("\n");
  return 0;
}
