#include <bits/stdc++.h>
using namespace std;
int n, v[100001], seg[400000], L[100001], R[100001];
int at, val, a, b;
void update(int n, int s, int e) {
  if (at < s || at > e) return;
  if (at == s && s == e) {
    seg[n] = max(seg[n], val);
    return;
  }
  update(n * 2, s, (s + e) / 2);
  update(n * 2 + 1, (s + e) / 2 + 1, e);
  seg[n] = max(seg[n * 2], seg[n * 2 + 1]);
}
int get(int n, int s, int e) {
  if (b < s || a > e || b == 0) return 0;
  if (s >= a && e <= b) return seg[n];
  return max(get(n * 2, s, (s + e) / 2), get(n * 2 + 1, (s + e) / 2 + 1, e));
}
string sol;
struct CF {
  int l, r, idx;
  bool operator<(const CF &x) const {
    if (l != x.l) return l < x.l;
    return r < x.r;
  }
};
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", v + i);
  int lis = 0;
  for (int i = n - 1; i >= 0; --i) {
    a = v[i] + 1;
    b = 100000;
    R[i] = 1 + get(1, 1, 100000);
    at = v[i];
    val = R[i];
    update(1, 1, 100000);
    lis = max(lis, R[i]);
  }
  memset(seg, 0, sizeof(seg));
  for (int i = 0; i < n; ++i) {
    a = 1;
    b = v[i] - 1;
    L[i] = 1 + get(1, 1, 100000);
    at = v[i];
    val = L[i];
    update(1, 1, 100000);
  }
  sol.resize(n, '1');
  for (int i = 0; i < n; ++i)
    if (L[i] + R[i] - 2 == lis - 1) sol[i] = '3';
  vector<CF> q;
  CF z;
  for (int i = 0; i < n; ++i) {
    z.l = L[i] - 1;
    z.r = R[i] - 1;
    if (z.l + z.r + 1 != lis) continue;
    z.idx = i;
    q.push_back(z);
  }
  sort(q.begin(), q.end());
  for (int i = 1; i < q.size(); ++i)
    if (q[i].l == q[i - 1].l) sol[q[i - 1].idx] = sol[q[i].idx] = '2';
  cout << sol << endl;
  return 0;
}
