#include <bits/stdc++.h>
using namespace std;
int n;
int f[500000], g[500000], a[500000];
map<long long, int> mp;
struct bit1 {
  int s[500000];
  int num;
  void add(int x, int z) {
    for (int i = x; i <= num; i += (i & -i)) s[i] = max(s[i], z);
  }
  int ask(int x) {
    int tmp = 0;
    for (int i = x; i >= 1; i -= (i & -i)) tmp = max(tmp, s[i]);
    return tmp;
  }
  void clear() { memset(s, 0, sizeof(s)); }
} s;
struct bit2 {
  int s[500000];
  int num;
  void add(int x, int z) {
    for (int i = x; i >= 1; i -= (i & -i)) s[i] = max(s[i], z);
  }
  int ask(int x) {
    int tmp = 0;
    for (int i = x; i <= num; i += (i & -i)) tmp = max(tmp, s[i]);
    return tmp;
  }
  void clear() { memset(s, 0, sizeof(s)); }
} t;
int main() {
  scanf("%d", &n);
  int mx = 0, lis = 0;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), mx = max(mx, a[i]);
  s.clear();
  s.num = mx + 1;
  for (int i = 1; i <= n; i++) {
    f[i] = s.ask(a[i] - 1) + 1;
    s.add(a[i], f[i]);
    lis = max(lis, f[i]);
  }
  t.clear();
  t.num = mx + 1;
  for (int i = n; i >= 1; i--) {
    g[i] = t.ask(a[i] + 1) + 1;
    t.add(a[i], g[i]);
  }
  for (int i = 1; i <= n; i++) {
    long long tmp = f[i] * (n + 1) + g[i];
    if (mp.find(tmp) == mp.end())
      mp[tmp] = 1;
    else
      mp[tmp]++;
  }
  for (int i = 1; i <= n; i++) {
    long long tmp = f[i] * (n + 1) + g[i];
    if (f[i] + g[i] - 1 < lis)
      printf("1");
    else if (mp[tmp] > 1)
      printf("2");
    else
      printf("3");
  }
  printf("\n");
  return 0;
}
