#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 5;
const long long linf = 1e18 + 5;
const int N = 1e5 + 5;
const int MAXN = N + 5;
int n, a[MAXN], dp[MAXN], mx[MAXN], kd[4 * MAXN + 5], res[MAXN], ans[MAXN], lis;
bool belong[MAXN];
int query(int root, int bas, int son, int x, int y) {
  if (son < x or y < bas) return 0;
  if (x <= bas and son <= y) return kd[root];
  return max(query((root << 1), bas, ((bas + son) >> 1), x, y),
             query(((root << 1) | 1), ((bas + son) >> 1) + 1, son, x, y));
}
int update(int root, int bas, int son, int x, int val) {
  if (son < x or x < bas) return kd[root];
  if (x <= bas and son <= x) return kd[root] = val;
  return kd[root] = max(
             update((root << 1), bas, ((bas + son) >> 1), x, val),
             update(((root << 1) | 1), ((bas + son) >> 1) + 1, son, x, val));
}
int main() {
  ios ::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    dp[i] = query(1, 1, N, 1, a[i] - 1) + 1;
    lis = max(lis, dp[i]);
    update(1, 1, N, a[i], dp[i]);
  }
  for (int i = n; i >= 1; i--) {
    if (dp[i] == lis or res[dp[i] + 1] > a[i]) {
      belong[i] = 1;
      res[dp[i]] = max(res[dp[i]], a[i]);
    }
  }
  for (int i = 1; i <= n; i++)
    if (belong[i]) ans[dp[i]]++;
  for (int i = 1; i <= n; i++)
    if (!belong[i])
      cout << 1;
    else
      cout << 2 + (ans[dp[i]] == 1);
  cout << '\n';
  0;
  return 0;
}
