#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int stk[MAXN], a[MAXN], l[MAXN], r[MAXN], cnt[MAXN] = {0}, top = 0, n, pos, len,
                                          ans[MAXN];
int lpos(int k) {
  if (k > stk[top]) {
    stk[++top] = k;
    return top;
  }
  int l = 1, r = top, mid, ret = 0;
  while (l <= r) {
    mid = (l + r) >> 1;
    if (stk[mid] < k) {
      ret = mid;
      l = mid + 1;
    } else
      r = mid - 1;
  }
  stk[++ret] = k;
  return ret;
}
int rpos(int k) {
  if (k < stk[top]) {
    stk[++top] = k;
    return top;
  }
  int l = 1, r = top, mid, ret = 0;
  while (l <= r) {
    mid = (l + r) >> 1;
    if (stk[mid] > k) {
      ret = mid;
      l = mid + 1;
    } else
      r = mid - 1;
  }
  stk[++ret] = k;
  return ret;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  stk[++top] = a[1];
  l[1] = 0;
  for (int i = 2; i <= n; ++i) {
    pos = lpos(a[i]);
    l[i] = pos - 1;
  }
  len = top;
  stk[top = 1] = a[n];
  r[n] = 0;
  for (int i = n - 1; i; --i) {
    pos = rpos(a[i]);
    r[i] = pos - 1;
  }
  for (int i = 1; i <= n; ++i)
    if (l[i] + 1 + r[i] == len)
      ++cnt[l[i] + 1];
    else
      ans[i] = 1;
  for (int i = 1; i <= n; ++i)
    if (ans[i])
      printf("1");
    else
      printf("%d", cnt[l[i] + 1] > 1 ? 2 : 3);
  puts("");
  return 0;
}
