#include <bits/stdc++.h>
using namespace std;
int a[100005], s[400020], dp1[100005], dp2[100005], n = 100005, ara[100005];
void build(int id = 1, int l = 0, int r = n) {
  if (r - l < 2) {
    s[id] = a[l];
    return;
  }
  int mid = (l + r) / 2;
  build(id * 2, l, mid);
  build(id * 2 + 1, mid, r);
  s[id] = max(s[id * 2], s[id * 2 + 1]);
}
void modify(int p, int x, int id = 1, int l = 0, int r = n) {
  if (r - l < 2) {
    s[id] = x;
    a[p] = x;
    return;
  }
  int mid = (l + r) / 2;
  if (p < mid)
    modify(p, x, id * 2, l, mid);
  else
    modify(p, x, id * 2 + 1, mid, r);
  s[id] = max(s[2 * id], s[2 * id + 1]);
}
int sum(int x, int y, int id = 1, int l = 0, int r = n) {
  if (x >= r or l >= y) return 0;
  if (x <= l && r <= y) return s[id];
  int mid = (l + r) / 2;
  return max(sum(x, y, id * 2, l, mid), sum(x, y, id * 2 + 1, mid, r));
}
char ans[100005];
vector<int> data[100005];
int main() {
  int i, N;
  scanf("%d", &N);
  for (i = 0; i < N; i++) scanf("%d", &ara[i]);
  memset(a, 0, sizeof(a));
  build();
  dp1[0] = 1;
  modify(ara[0], 1);
  for (i = 1; i < N; i++) {
    dp1[i] = 1 + sum(0, ara[i]);
    modify(ara[i], dp1[i]);
  }
  memset(a, 0, sizeof(a));
  build();
  modify(ara[N - 1], 1);
  dp2[N - 1] = 1;
  for (i = N - 2; i >= 0; i--) {
    dp2[i] = 1 + sum(ara[i] + 1, n);
    modify(ara[i], dp2[i]);
  }
  int l = 0;
  for (i = 0; i < N; i++) l = max(l, dp1[i] + dp2[i] - 1);
  memset(ans, 0, sizeof(ans));
  for (i = 0; i < N; i++) {
    if (dp1[i] + dp2[i] - 1 != l) ans[i] = '1';
  }
  for (i = 0; i < N; i++) {
    if (ans[i]) continue;
    data[dp1[i]].push_back(i);
  }
  for (i = 0; i < 100005; i++) {
    if (data[i].size() == 1) ans[data[i][0]] = '3';
  }
  for (i = 0; i < N; i++)
    if (!ans[i]) ans[i] = '2';
  printf("%s\n", ans);
  return 0;
}
