#include <bits/stdc++.h>
using namespace std;
int n, mx = 0;
int a[100005];
int Max[100005 << 4];
int f[100005], d[100005];
void Init() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    for (int j = a[i] - 1; j; j -= j & -j) f[i] = max(f[i], Max[j]);
    f[i]++;
    if (f[i] > mx) mx = f[i];
    for (int j = a[i]; j < 100005 << 4; j += j & -j) Max[j] = max(f[i], Max[j]);
  }
  memset(Max, 0, sizeof(Max));
  for (int i = n; i >= 1; i--) {
    for (int j = a[i] + 1; j < 100005 << 4; j += j & -j)
      d[i] = max(d[i], Max[j]);
    d[i]++;
    for (int j = a[i]; j; j -= j & -j) Max[j] = max(d[i], Max[j]);
  }
}
int vis[100005];
int Ans[100005];
void Work() {
  memset(vis, 0, sizeof(vis));
  memset(Ans, 0, sizeof(Ans));
  for (int i = 1; i <= n; i++)
    if (f[i] + d[i] - 1 < mx)
      Ans[i] = 1;
    else
      vis[f[i]]++;
  for (int i = 1; i <= n; i++)
    if (!Ans[i] && vis[f[i]] == 1) Ans[i] = 3;
  for (int i = 1; i <= n; i++)
    if (!Ans[i])
      cout << "2";
    else
      printf("%d", Ans[i]);
  cout << endl;
}
int main() {
  Init();
  Work();
  return 0;
}
