#include <bits/stdc++.h>
using namespace std;
bool cmp(const pair<int, int>& a, const pair<int, int>& b) {
  if (a.first == b.first) return a.second > b.second;
  return a.first < b.first;
}
const int N = 1e5 + 10;
int n;
struct segTree {
  pair<int, long long> t[2 * N];
  void reset() {
    for (int i = 0; i < 2 * n; i++) t[i] = {0, 0};
  }
  pair<int, long long> combine(const pair<int, int>& a,
                               const pair<int, int>& b) {
    if (a.first == b.first) return {a.first, a.second + b.second};
    return max(a, b);
  }
  void add(int p, pair<int, long long> val) {
    for (t[p += n] = val; p > 1; p >>= 1) t[p >> 1] = combine(t[p], t[p ^ 1]);
  }
  pair<int, long long> query(int l, int r) {
    pair<int, long long> res = {0, 0};
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
      if (l & 1) res = combine(res, t[l++]);
      if (r & 1) res = combine(res, t[--r]);
    }
    return res;
  }
} st;
pair<int, int> a[N];
int res_len[N];
long long res_cnt[N];
long long cnt[N];
int len[N];
int ans[N];
void calc() {
  st.reset();
  for (int i = 0; i < n; i++) {
    int pos = a[i].second;
    auto ans = st.query(0, pos);
    len[pos] = ans.first + 1;
    cnt[pos] = max(1LL, ans.second);
    st.add(pos, {len[pos], cnt[pos]});
  }
}
int len_cnt[N];
bool can_be_3[N];
int f_len[N];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    a[i] = {x, i};
  }
  sort(a, a + n, cmp);
  calc();
  copy(len, len + n, f_len);
  for (int i = 0; i < n; i++) res_len[i] += len[i], res_cnt[i] = cnt[i];
  for (int i = 0; i < n; i++) a[i] = {-a[i].first, n - 1 - a[i].second};
  sort(a, a + n, cmp);
  calc();
  reverse(cnt, cnt + n);
  reverse(len, len + n);
  for (int i = 0; i < n; i++) res_len[i] += len[i] - 1, res_cnt[i] *= cnt[i];
  int ans_len = *max_element(res_len, res_len + n);
  for (int i = 0; i < n; i++) {
    ans[i] = 1;
    if (res_len[i] == ans_len) {
      ans[i]++;
    }
  }
  for (int i = 0; i < n; i++)
    if (ans[i] == 2) len_cnt[f_len[i]]++;
  for (int i = 0; i < n; i++)
    if (ans[i] == 2)
      if (len_cnt[f_len[i]] == 1) ans[i]++;
  for (int i = 0; i < n; i++) printf("%d", ans[i]);
}
