#include <bits/stdc++.h>
using namespace std;
constexpr int N = 1e6 + 10;
long long n, a[N], ind[N], pos, lis[N], last[N], cnt[N], mx;
bool can[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  memset(lis, 63, sizeof(lis));
  for (int i = 0; i < n; i++) {
    pos = lower_bound(lis, lis + n, a[i]) - lis;
    ind[i] = pos;
    lis[pos] = a[i];
    mx = max(mx, pos);
  }
  memset(last, -1, sizeof(last));
  for (int i = n - 1; ~i; i--) {
    if (ind[i] == mx || (cnt[ind[i] + 1] && can[last[ind[i] + 1]] &&
                         a[i] < a[last[ind[i] + 1]])) {
      can[i] = true;
      last[ind[i]] = i;
      cnt[ind[i]]++;
    }
  }
  for (int i = 0; i < n; i++) {
    if (!can[i])
      cout << 1;
    else if (cnt[ind[i]] == 1)
      cout << 3;
    else
      cout << 2;
  }
  cout << '\n';
  return 0;
}
