#include <bits/stdc++.h>
using namespace std;
const int oo = 1e9;
const int N = 1e5 + 5;
int arr[N], dp1[N], dp2[N], freq[N];
struct maxBit {
  int bit[N];
  int n;
  maxBit() {
    n = N;
    memset(bit, 0, sizeof(bit));
  }
  int getMax(int r) {
    int ret = 0;
    for (; r >= 0; r = (r & (r + 1)) - 1) ret = max(ret, bit[r]);
    return ret;
  }
  void update(int i, int val) {
    for (; i < n; i = i | (i + 1)) bit[i] = max(bit[i], val);
  }
};
struct revBit {
  int bit[N];
  int n;
  revBit() {
    n = N;
    memset(bit, 0, sizeof(bit));
  }
  int getMax(int l) {
    int ret = 0;
    for (; l < n; l = (l | (l + 1))) ret = max(ret, bit[l]);
    return ret;
  }
  void update(int i, int val) {
    for (; i >= 0; i = (i & (i + 1)) - 1) bit[i] = max(bit[i], val);
  }
};
int main() {
  int n;
  scanf("%d", &(n));
  maxBit bit1;
  for (int i = 0; i < n; i++) {
    scanf("%d", &(arr[i]));
    dp1[i] = bit1.getMax(arr[i] - 1) + 1;
    bit1.update(arr[i], dp1[i]);
  }
  revBit bit2;
  for (int i = n - 1; i >= 0; i--) {
    dp2[i] = bit2.getMax(arr[i] + 1) + 1;
    bit2.update(arr[i], dp2[i]);
  }
  int lis = bit1.getMax(N - 1);
  for (int i = 0; i < n; i++) {
    if (dp1[i] + dp2[i] - 1 == lis) freq[dp1[i]]++;
  }
  for (int i = 0; i < n; i++) {
    if (dp1[i] + dp2[i] - 1 != lis)
      printf("1");
    else if (freq[dp1[i]] != 1)
      printf("2");
    else
      printf("3");
  }
  return 0;
}
