#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int a[maxn], lis[maxn], lds[maxn];
int l[maxn], r[maxn], lcnt[maxn];
int main() {
  int n;
  cin >> n;
  memset(lis, 63, sizeof(lis));
  memset(lds, 63, sizeof(lds));
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    l[i] = lower_bound(lis, lis + n, a[i]) - lis;
    lis[l[i]] = a[i];
  }
  for (int i = n - 1; i > -1; i--) {
    r[i] = lower_bound(lds, lds + n, -a[i]) - lds;
    lds[r[i]] = -a[i];
  }
  int lissize = lower_bound(lis, lis + n, lis[maxn - 1]) - lis;
  for (int i = 0; i < n; i++)
    if (l[i] + r[i] + 1 >= lissize) lcnt[l[i]]++;
  for (int i = 0; i < n; i++) {
    if (l[i] + r[i] + 1 < lissize)
      cout << 1;
    else if (lcnt[l[i]] > 1)
      cout << 2;
    else
      cout << 3;
  }
  cout << '\n';
  return 0;
}
