#include <bits/stdc++.h>
using namespace std;
unsigned long long cntv[100005 << 2];
int maxv[100005 << 2];
void push_up(int rt) {
  maxv[rt] = maxv[rt << 1];
  cntv[rt] = cntv[rt << 1];
  if (maxv[rt << 1 | 1] > maxv[rt]) {
    maxv[rt] = maxv[rt << 1 | 1];
    cntv[rt] = cntv[rt << 1 | 1];
  } else if (maxv[rt << 1 | 1] == maxv[rt]) {
    cntv[rt] += cntv[rt << 1 | 1];
    cntv[rt] %= 1000000007;
  }
}
void build(int rt, int L, int R) {
  maxv[rt] = 0, cntv[rt] = 0;
  if (L == R) return;
  int mid = L + R >> 1;
  build(rt << 1, L, mid);
  build(rt << 1 | 1, mid + 1, R);
}
int key;
unsigned long long num;
void query(int rt, int L, int R, int l, int r) {
  if (l <= L && R <= r) {
    if (maxv[rt] > key) {
      key = maxv[rt];
      num = cntv[rt];
    } else if (maxv[rt] == key) {
      num += cntv[rt];
      num %= 1000000007;
    }
    return;
  }
  int mid = L + R >> 1;
  if (l <= mid) query(rt << 1, L, mid, l, r);
  if (r > mid) query(rt << 1 | 1, mid + 1, R, l, r);
}
void update(int rt, int L, int R, int p, int kk, unsigned long long val) {
  if (L == R) {
    if (kk > maxv[rt]) {
      maxv[rt] = kk;
      cntv[rt] = val;
    } else if (kk == maxv[rt]) {
      cntv[rt] += val;
      cntv[rt] %= 1000000007;
    }
    return;
  }
  int mid = L + R >> 1;
  if (p <= mid)
    update(rt << 1, L, mid, p, kk, val);
  else
    update(rt << 1 | 1, mid + 1, R, p, kk, val);
  push_up(rt);
}
int n, m;
int h[100005];
int value[100005];
char ss[100005];
int f[100005];
unsigned long long g[100005];
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> h[i];
    value[m++] = h[i];
  }
  sort(value, value + m);
  m = unique(value, value + m) - value;
  build(1, 0, m - 1);
  int D = 0;
  unsigned long long M = 0;
  for (int i = 1; i <= n; i++) {
    int p = lower_bound(value, value + m, h[i]) - value;
    key = 0, num = 1;
    if (p) {
      query(1, 0, m - 1, 0, p - 1);
    }
    f[i] = key + 1;
    g[i] = num;
    if (f[i] > D) {
      D = f[i];
      M = g[i];
    } else if (f[i] == D) {
      M += g[i];
      M %= 1000000007;
    }
    update(1, 0, m - 1, p, f[i], g[i]);
  }
  build(1, 0, m - 1);
  for (int i = n; i >= 1; i--) {
    int p = lower_bound(value, value + m, h[i]) - value;
    key = 0, num = 1;
    if (p < m - 1) {
      query(1, 0, m - 1, p + 1, m - 1);
    }
    if (key + f[i] == D) {
      if (num * g[i] % 1000000007 == M) {
        ss[i] = '3';
      } else {
        ss[i] = '2';
      }
    } else {
      ss[i] = '1';
    }
    update(1, 0, m - 1, p, key + 1, num);
  }
  ss[n + 1] = 0;
  puts(ss + 1);
  return 0;
}
