#include <bits/stdc++.h>
using namespace std;
const long long inf = (long long)1e18;
long long MOD = (long long)998244353;
const int N = (int)1e5 + 3;
int n, sLIS[N], eLIS[N], arr[N], seg[4 * N], freq[N];
void update(int pos, int val, int id = 0, int l = 0, int r = N - 1) {
  if (l == r) {
    seg[id] = val;
    return;
  }
  int mid = l + (r - l) / 2;
  if (pos <= mid)
    update(pos, val, id * 2 + 1, l, mid);
  else
    update(pos, val, id * 2 + 2, mid + 1, r);
  seg[id] = max(seg[id * 2 + 1], seg[id * 2 + 2]);
}
int query(int s, int e, int id = 0, int l = 0, int r = N - 1) {
  if (e < l || s > r) {
    return 0;
  }
  if (s <= l && e >= r) {
    return seg[id];
  }
  int mid = l + (r - l) / 2;
  return max(query(s, e, id * 2 + 1, l, mid),
             query(s, e, id * 2 + 2, mid + 1, r));
}
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> arr[i];
  for (int i = 0; i < n; ++i) {
    eLIS[i] = query(0, arr[i] - 1) + 1;
    update(arr[i], eLIS[i]);
  }
  memset(seg, 0, sizeof(seg));
  for (int i = n - 1; i >= 0; --i) {
    sLIS[i] = query(arr[i] + 1, N - 1) + 1;
    update(arr[i], sLIS[i]);
  }
  for (int i = 0; i < n; ++i) {
    if (eLIS[i] + sLIS[i] - 1 == seg[0]) {
      freq[eLIS[i]]++;
    }
  }
  for (int i = 0; i < n; ++i) {
    if (eLIS[i] + sLIS[i] - 1 == seg[0]) {
      if (freq[eLIS[i]] == 1)
        printf("3");
      else
        printf("2");
    } else {
      printf("1");
    }
  }
}
