#include <bits/stdc++.h>
using namespace std;
int a[100010], in[100010];
int que[100010], len;
int dp[100010], idp[100010];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", a + i);
  len = 0;
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    int id = lower_bound(que, que + len, a[i]) - que;
    dp[i] = id + 1;
    ans = max(ans, dp[i]);
    que[id] = a[i];
    if (id == len) ++len;
  }
  len = 0;
  for (int i = n; i >= 1; --i) {
    int id = lower_bound(que, que + len, -a[i]) - que;
    idp[i] = id + 1;
    que[id] = -a[i];
    if (id == len) ++len;
  }
  for (int i = 1; i <= n; ++i) {
    if (dp[i] + idp[i] == ans + 1)
      a[i] = 2, ++in[dp[i]];
    else
      a[i] = 1;
  }
  for (int i = 1; i <= n; ++i) {
    if (a[i] == 2 && in[dp[i]] == 1) a[i] = 3;
    printf("%d", a[i]);
  }
  puts("");
}
