#include <bits/stdc++.h>
using namespace std;
const int SIZEN = 100000 + 5;
const int INF = 0x7f7f7f7f;
int a[SIZEN];
int lenL[SIZEN], lenR[SIZEN];
int f[SIZEN];
char result[SIZEN];
int cnt[SIZEN];
int lis(int n, int len[SIZEN]) {
  int now = 0;
  f[0] = -INF;
  for (int i = 1; i <= n; i++) {
    if (a[i] > f[now]) {
      f[++now] = a[i];
      len[i] = now;
    } else {
      len[i] = lower_bound(f + 1, f + 1 + now, a[i]) - f;
      f[len[i]] = a[i];
    }
  }
  return now;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  lis(n, lenL);
  reverse(a + 1, a + 1 + n);
  for (int i = 1; i <= n; i++) a[i] = -a[i];
  int len = lis(n, lenR);
  reverse(lenR + 1, lenR + 1 + n);
  for (int i = 1; i <= n; i++) {
    if (lenL[i] + lenR[i] != len + 1) {
      result[i] = '1';
      continue;
    }
    cnt[lenL[i]]++;
  }
  for (int i = 1; i <= n; i++)
    if (result[i] == '1')
      putchar('1');
    else if (cnt[lenL[i]] == 1)
      putchar('3');
    else
      putchar('2');
  return 0;
}
