#include <bits/stdc++.h>
const long long N = 1e5 + 5;
const int MOD = 1e9 + 7;
const long long base = 81799;
using namespace std;
int n;
int a[N];
pair<int, int> st[4 * N], L[N], R[N];
pair<int, int> Compare(pair<int, int> a, pair<int, int> b) {
  if (a > b) swap(a, b);
  if (a.first != b.first)
    return b;
  else
    return {a.first, (a.second + b.second) % MOD};
}
void update(int id, int l, int r, int pos, pair<int, int> val) {
  if (l > pos || r < pos) return;
  if (l == r) {
    st[id] = Compare(st[id], val);
    return;
  }
  int mid = (l + r) / 2;
  update(id * 2, l, mid, pos, val);
  update(id * 2 + 1, mid + 1, r, pos, val);
  st[id] = Compare(st[id * 2], st[id * 2 + 1]);
}
pair<int, int> get(int id, int l, int r, int u, int v) {
  int mid = (l + r) / 2;
  if (l > v || r < u) return {0, 0};
  if (l >= u && r <= v)
    return st[id];
  else
    return Compare(get(id * 2, l, mid, u, v),
                   get(id * 2 + 1, mid + 1, r, u, v));
}
void xuly() {
  cin >> n;
  for (int i = (1); i <= (n); ++i) cin >> a[i];
  pair<int, int> ans = {0, 0};
  for (int i = (1); i <= (4e5); ++i) st[i] = {0, 0};
  for (int i = (1); i <= (n); ++i) {
    pair<int, int> k = get(1, 1, 1e5, 1, a[i] - 1);
    if (k.first + k.second == 0) k = {0, 1};
    L[i] = k;
    update(1, 1, 1e5, a[i], {k.first + 1, k.second});
    ans = Compare({k.first + 1, k.second}, ans);
  }
  for (int i = (1); i <= (4e5); ++i) st[i] = {0, 0};
  for (int i = (n); i >= (1); --i) {
    pair<int, int> k = get(1, 1, 1e5, a[i] + 1, 1e5);
    if (k.first + k.second == 0) k = {0, 1};
    R[i] = k;
    update(1, 1, 1e5, a[i], {k.first + 1, k.second});
  }
  for (int i = (1); i <= (n); ++i) {
    if (L[i].first + R[i].first + 1 != ans.first) {
      cout << 1;
      continue;
    }
    int t = (1ll * L[i].second * R[i].second) % MOD;
    if (t == ans.second)
      cout << 3;
    else
      cout << 2;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  xuly();
}
