#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)1e5 + 20;
int a[maxn], b[maxn], m[maxn], inc[maxn], des[maxn], cnt[maxn];
int n, s;
void ins(int a[], int i, int v) {
  for (; i < maxn; i += i & (-i)) a[i] = max(a[i], v);
}
int qry(int a[], int i) {
  int ret = 0;
  for (; i; i -= i & (-i)) ret = max(a[i], ret);
  return ret;
}
void gao(int a[], int f[], bool flag) {
  memset(m, 0, maxn * sizeof(int));
  for (int i = 0; i < n; i++) {
    f[i] = qry(m, a[i] - 1) + 1;
    ins(m, a[i], f[i]);
    if (flag == 1) {
      s = max(s, f[i]);
      cnt[f[i]] += 1;
    }
  }
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[n - 1 - i] = maxn - a[i] - 10;
  }
  gao(a, inc, 1);
  gao(b, des, 0);
  for (int i = 0; i < n; i++) {
    if (inc[i] + des[n - 1 - i] - 1 != s) {
      cnt[inc[i]] -= 1;
    }
  }
  for (int i = 0; i < n; i++) {
    int x;
    if (inc[i] + des[n - 1 - i] - 1 != s) {
      x = 1;
    } else if (cnt[inc[i]] != 1) {
      x = 2;
    } else {
      x = 3;
    }
    cout << x;
  }
  cout << endl;
  return 0;
}
