#include <bits/stdc++.h>
using namespace std;
const int N = 1000 * 100 + 10, mod = 100000007;
vector<int> f[N];
int a[N], ans[N];
int n;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<int> v;
  for (int i = 0; i < n; i++) {
    int val = a[i];
    int pos = lower_bound(v.begin(), v.end(), val) - v.begin();
    f[pos].push_back(i);
    if (pos < int(v.size()))
      v[pos] = val;
    else
      v.push_back(val);
  }
  int len = int(v.size()) - 1;
  if (int(f[len].size()) > 1)
    for (int i = 0; i < int(f[len].size()); i++) ans[f[len][i]] = 2;
  else
    ans[f[len][0]] = 3;
  for (int i = len - 1; i >= 0; i--) {
    vector<int> ft;
    int p1 = int(f[i + 1].size()) - 1, t = 0;
    for (int p2 = int(f[i].size()) - 1; p2 >= 0; p2--) {
      while (p1 > 0 && f[i + 1][p1 - 1] > f[i][p2]) p1--;
      if (a[f[i][p2]] >= a[f[i + 1][p1]] || f[i][p2] > f[i + 1][p1])
        ans[f[i][p2]] = -1;
      else
        t++;
    }
    for (int p2 = 0; p2 < int(f[i].size()); p2++) {
      if (ans[f[i][p2]] == -1) {
        ans[f[i][p2]] = 1;
        continue;
      }
      ft.push_back(f[i][p2]);
      if (t > 1) ans[f[i][p2]] = 2;
      if (t == 1) ans[f[i][p2]] = 3;
    }
    f[i] = ft;
  }
  for (int i = 0; i < n; i++) cout << ans[i];
  cout << endl;
}
