#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
int cnt[MAXN], ans[MAXN], a[MAXN], lf[MAXN], par[MAXN];
vector<int> v;
bool cmp1(int i, int j) { return a[i] < a[j]; }
bool cmp2(int i, int j) { return a[i] > a[j]; }
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    ans[i] = 1;
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    int ind = lower_bound(v.begin(), v.end(), i, cmp1) - v.begin();
    lf[i] = ind;
    if (ind == v.size())
      v.push_back(i);
    else
      v[ind] = i;
    if (ind > 0)
      par[i] = v[ind - 1];
    else
      par[i] = -1;
  }
  int mx = v.size();
  int now = v.back();
  while (now != -1) {
    cnt[now]++;
    now = par[now];
  }
  v.clear();
  for (int i = n - 1; i >= 0; i--) {
    int ind = lower_bound(v.begin(), v.end(), i, cmp2) - v.begin();
    if (lf[i] + ind + 1 == mx) ans[i] = 2;
    if (ind == v.size())
      v.push_back(i);
    else
      v[ind] = i;
    if (ind > 0)
      par[i] = v[ind - 1];
    else
      par[i] = -1;
  }
  now = v.back();
  while (now != -1) {
    cnt[now]++;
    now = par[now];
  }
  for (int i = 0; i < n; i++)
    if (cnt[i] == 2)
      cout << 3;
    else
      cout << ans[i];
  cout << endl;
}
