#include <bits/stdc++.h>
using namespace std;
int n, A[100005], dpl[100005], dpr[100005], cnt[100005],
    top = 0, llis[100005], rlis[100005], ans[100005];
int lpos(int k) {
  if (dpl[top] < k) {
    dpl[++top] = k;
    return top;
  }
  int l = 1, r = top, res = 0, mid;
  while (l <= r) {
    mid = (l + r) >> 1;
    if (dpl[mid] < k) {
      res = mid, l = mid + 1;
    } else
      r = mid - 1;
  }
  dpl[++res] = k;
  return res;
}
int rpos(int k) {
  if (dpr[top] > k) {
    dpr[++top] = k;
    return top;
  }
  int l = 1, r = top, mid, res = 0;
  while (l <= r) {
    mid = (l + r) >> 1;
    if (dpr[mid] > k) {
      res = mid, l = mid + 1;
    } else
      r = mid - 1;
  }
  dpr[++res] = k;
  return res;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", A + i);
  dpl[top = 1] = A[0];
  llis[0] = 1;
  for (int i = 1; i < n; i++) {
    int pos = lpos(A[i]);
    llis[i] = pos;
  }
  dpr[top = 1] = A[n - 1];
  rlis[n - 1] = 1;
  for (int i = n - 2; i >= 0; i--) {
    int pos = rpos(A[i]);
    rlis[i] = pos;
  }
  memset(cnt, 0, sizeof(cnt));
  memset(ans, 0, sizeof(ans));
  for (int i = 0; i < n; i++) {
    if (llis[i] + rlis[i] == top + 1) {
      cnt[llis[i]]++;
      ans[i] = 1;
    }
  }
  for (int i = 0; i < n; i++)
    printf("%d", ans[i] ? (cnt[llis[i]] > 1 ? 2 : 3) : 1);
  printf("\n");
  return 0;
}
