#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const double PI = acos(-1.0);
int a[100005], s[100005], dp1[100005], dp2[100005], b[100005], ans[100005];
int main() {
  int n, i, maxlen, k;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]), b[n - i + 1] = -a[i];
  for (i = 0; i <= n; i++) s[i] = 0x3f3f3f3f;
  maxlen = 0;
  for (i = 1; i <= n; i++) {
    k = lower_bound(s, s + n, a[i]) - s;
    s[k] = a[i];
    dp1[i] = k + 1;
    maxlen = max(maxlen, dp1[i]);
  }
  for (i = 0; i <= n; i++) s[i] = 0x3f3f3f3f;
  for (i = 1; i <= n; i++) {
    k = lower_bound(s, s + n, b[i]) - s;
    s[k] = b[i];
    dp2[n - i + 1] = k + 1;
  }
  k = 0;
  memset(ans, -1, sizeof(ans));
  for (i = 1; i <= n; i++) {
    if (dp1[i] + dp2[i] - 1 < maxlen)
      ans[i] = 1;
    else
      s[k++] = dp1[i];
  }
  sort(s, s + k);
  for (i = 1; i <= n; i++) {
    if (ans[i] == 1)
      printf("1");
    else {
      if (upper_bound(s, s + k, dp1[i]) - lower_bound(s, s + k, dp1[i]) > 1)
        printf("2");
      else
        printf("3");
    }
  }
  puts("");
}
