#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
const int mod = 1e9 + 7;
int a[N];
int f1[N], f2[N], f[N];
int b[N];
int vis[N];
int top = 0;
int bin_s(int num, int l, int r) {
  int res = 0;
  while (l <= r) {
    int m = (l + r) >> 1;
    if (b[m] >= num)
      res = m, r = m - 1;
    else
      l = m + 1;
  }
  return res;
}
int bin_ss(int num, int l, int r) {
  int res = 0;
  while (l <= r) {
    int m = (l + r) >> 1;
    if (b[m] <= num)
      res = m, r = m - 1;
    else
      l = m + 1;
  }
  return res;
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  top = 0;
  for (int i = 1; i <= n; i++) {
    if (top == 0 || a[i] > b[top]) {
      b[++top] = a[i];
      f1[i] = top;
    } else {
      int id = bin_s(a[i], 1, top);
      b[id] = a[i];
      f1[i] = id;
    }
  }
  top = 0;
  for (int i = n; i > 0; i--) {
    if (top == 0 || a[i] < b[top]) {
      b[++top] = a[i];
      f2[i] = top;
    } else {
      int id = bin_ss(a[i], 1, top);
      b[id] = a[i];
      f2[i] = id;
    }
  }
  int lis = top;
  memset(vis, 0, sizeof(vis));
  for (int i = 1; i <= n; i++) {
    if (f1[i] + f2[i] - 1 == lis) {
      vis[f1[i]]++;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (f1[i] + f2[i] - 1 < lis)
      putchar('1');
    else if (vis[f1[i]] == 1)
      putchar('3');
    else
      putchar('2');
  }
  puts("");
  return 0;
}
