#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 10;
const long long MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long LLINF = 0x3f3f3f3f3f3f3f3f;
const long double EPS = 1e-10;
const long double PI = acos(-1);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  vector<int> sz1(MAX, 1), sz2(MAX, 1), f(MAX, 0), got(MAX, 0);
  int n, a[MAX], lis[MAX], c;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  c = 0;
  for (int i = 0; i < n; i++) {
    int ind = lower_bound(lis, lis + c, a[i]) - lis;
    lis[ind] = a[i];
    c += (ind == c);
    f[i] = ind;
    sz1[i] += ind;
  }
  c = 0;
  for (int i = n - 1; i >= 0; i--) {
    int ind = lower_bound(lis, lis + c, a[i], greater<int>()) - lis;
    lis[ind] = a[i];
    c += (ind == c);
    sz2[i] += ind;
  }
  for (int i = 0; i < n; i++)
    if (sz1[i] + sz2[i] - 1 == c) got[f[i]]++;
  for (int i = 0; i < n; i++) {
    if (sz1[i] + sz2[i] - 1 < c)
      cout << 1;
    else if (got[f[i]] > 1)
      cout << 2;
    else
      cout << 3;
  }
  cout << '\n';
  return 0;
}
