#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 7;
const int inf = 0x3f3f3f3f;
int n;
int a[maxn];
int f[maxn], g[maxn];
int an[maxn];
struct LIS {
  int n, s[maxn];
  void init() { n = 0; }
  int find(int x) { return lower_bound(s, s + n, x) - s; }
  void modify(int pos, int val) {
    s[pos] = val;
    n = max(n, pos + 1);
  }
} in, de;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  in.init();
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    f[i] = in.find(a[i]);
    in.modify(f[i], a[i]);
    f[i] += 1;
    ans = max(f[i], ans);
  }
  in.init();
  for (int i = n; i; i--) {
    g[i] = in.find(-a[i]);
    in.modify(g[i], -a[i]);
    g[i] += 1;
  }
  map<pair<int, int>, int> mp;
  for (int i = 1; i <= n; i++) {
    if (f[i] + g[i] < ans + 1) {
      an[i] = -1;
    } else {
      mp[make_pair(f[i], g[i])]++;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (an[i] == -1) {
      printf("1");
    } else {
      if (mp[make_pair(f[i], g[i])] == 1) {
        printf("3");
      } else {
        printf("2");
      }
    }
  }
  printf("\n");
  return 0;
}
