#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
int n, big;
int a[MAXN];
int t[MAXN];
int f[MAXN];
int g[MAXN];
int ans[MAXN];
int tim[MAXN];
int Find(int x) {
  int ret = 0;
  for (; x; x -= (x & (-x))) ret = max(t[x], ret);
  return ret;
}
void Add(int x, int d) {
  for (; x <= 100000; x += (x & (-x))) t[x] = max(t[x], d);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (int i = 1; i <= n; ++i) {
    f[i] = Find(a[i] - 1) + 1;
    Add(a[i], f[i]);
  }
  memset(t, 0, sizeof(t));
  for (int i = n; i >= 1; --i) {
    g[i] = Find(100000 - a[i]) + 1;
    Add(100001 - a[i], g[i]);
  }
  for (int i = 1; i <= n; ++i) big = max(big, f[i] + g[i]);
  for (int i = 1; i <= n; ++i)
    if (big != f[i] + g[i])
      ans[i] = 1;
    else
      ++tim[f[i]];
  for (int i = 1; i <= n; ++i)
    if (big == f[i] + g[i]) {
      if (tim[f[i]] > 1)
        ans[i] = 2;
      else
        ans[i] = 3;
    }
  for (int i = 1; i <= n; ++i) printf("%d", ans[i]);
  return 0;
}
