#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 10;
set<pair<int, int> > s[MAXN];
vector<int> dp;
int a[MAXN], dp2[MAXN], ans[MAXN];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    int ind = lower_bound(dp.begin(), dp.end(), a[i]) - dp.begin();
    if (ind == dp.size())
      dp.push_back(a[i]);
    else
      dp[ind] = min(dp[ind], a[i]);
    dp2[i] = ind + 1;
  }
  for (int i = n - 1; i > -1; i--) {
    if (dp2[i] == dp.size())
      s[dp2[i]].insert(make_pair(a[i], i));
    else {
      if (s[dp2[i] + 1].size() and s[dp2[i] + 1].rbegin()->first > a[i])
        s[dp2[i]].insert(make_pair(a[i], i));
    }
  }
  for (int i = 0; i < n; i++) ans[i] = 1;
  for (int i = 1; i <= n; i++) {
    int is = 1;
    if (s[i].size() > 1)
      is = 2;
    else if (s[i].size() == 1)
      is = 3;
    while (s[i].size())
      ans[s[i].begin()->second] = is, s[i].erase(s[i].begin());
  }
  for (int i = 0; i < n; i++) cout << ans[i];
  return 0;
}
