#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 10;
long long n, len, L[N], R[N], a[N], b[N], pos, cnt[N];
vector<long long> lis1, lis2;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[n - 1 - i] = -a[i];
  }
  for (int i = 0; i < n; i++) {
    if (!lis1.size() or lis1.back() < a[i]) {
      pos = lis1.size();
      lis1.push_back(a[i]);
    } else {
      pos = lower_bound(lis1.begin(), lis1.end(), a[i]) - lis1.begin();
      lis1[pos] = a[i];
    }
    L[i] = pos + 1;
    if (!lis2.size() or lis2.back() < b[i]) {
      pos = lis2.size();
      lis2.push_back(b[i]);
    } else {
      pos = lower_bound(lis2.begin(), lis2.end(), b[i]) - lis2.begin();
      lis2[pos] = b[i];
    }
    R[i] = pos + 1;
  }
  len = lis1.size();
  for (int i = 0; i < n; i++)
    if (L[i] + R[n - 1 - i] - 1 == len) cnt[L[i]]++;
  for (int i = 0; i < n; i++) {
    if (L[i] + R[n - 1 - i] - 1 != len) {
      cout << 1;
      continue;
    }
    if (cnt[L[i]] == 1) {
      cout << 3;
      continue;
    }
    cout << 2;
  }
}
