#include <bits/stdc++.h>
using namespace std;
const int INF = (1LL << 31) - 1;
const long long int LINF = (1LL << 62) - 1;
const int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};
const int MOD = (int)(1e9) + 7;
const int NMAX = 100000 + 5;
const int MMAX = 100000 + 5;
const int KMAX = 100000 + 5;
const int PMAX = 100000 + 5;
const int LMAX = 100000 + 5;
const int VMAX = 100000 + 5;
int N, best;
int V[NMAX];
int T[NMAX];
int F1[NMAX];
int F2[NMAX];
int F[NMAX];
int sol[NMAX];
int main() {
  int i, j;
  scanf("%d", &N);
  for (i = 1; i <= N; i++) scanf("%d", &V[i]);
  for (i = 1; i <= N; i++) {
    T[i] = INF;
    j = lower_bound(T + 1, T + i + 1, V[i]) - T;
    T[j] = V[i];
    F1[i] = j;
    best = max(best, j);
  }
  for (i = N; i >= 1; i--) {
    T[N - i + 1] = INF;
    j = lower_bound(T + 1, T + N - i + 2, -V[i]) - T;
    T[j] = -V[i];
    F2[i] = j;
  }
  for (i = 1; i <= N; i++)
    if (F1[i] + F2[i] - 1 != best)
      sol[i] = 1;
    else {
      sol[i] = 2;
      F[F1[i]]++;
    }
  for (i = 1; i <= N; i++)
    if (sol[i] == 2 && F[F1[i]] == 1) sol[i] = 3;
  for (i = 1; i <= N; i++) printf("%d", sol[i]);
  return 0;
}
