#include <bits/stdc++.h>
using namespace std;
template <class T>
bool Maximize(T &v, T nv) {
  if (nv > v) return v = nv, 1;
  return 0;
}
template <class T>
bool Minimize(T &v, T nv) {
  if (nv < v) return v = nv, 1;
  return 0;
}
template <class T>
T Mod(T &v, T mod) {
  return v = (v % mod + mod) % mod;
}
const long long INFLL = numeric_limits<long long>::max();
const long INF = numeric_limits<long>::max(), N = (long)1e5 + 1,
           MOD = (long)1e9 + 7;
long Plus(long a, long b) { return (a + b) % MOD; }
long Mul(long a, long b) { return (1LL * a * b) % MOD; }
pair<long, long> Combine(pair<long, long> a, pair<long, long> b) {
  pair<long, long> v = std::max(a, b);
  if (a.first == b.first) v.second = v.first ? Plus(a.second, b.second) : 1;
  return v;
}
class SegmentTree {
  struct Node {
    long l, r;
    Node *left, *right;
    pair<long, long> v;
    Node(long i) : l(i), r(i), left(0), right(0), v(make_pair(0, 0)) {}
    Node(long l, long r, Node *left, Node *right)
        : l(l), r(r), left(left), right(right) {
      Update();
    }
    void Update() { v = Combine(left->v, right->v); }
    bool IsLeaf() { return l == r; }
  };
  Node *root;
  Node *build(long l, long r) {
    return l == r ? new Node(l)
                  : new Node(l, r, build(l, (l + r) / 2),
                             build((l + r) / 2 + 1, r));
  }
  pair<long, long> max(Node *v, long l, long r) {
    if (v->l > r || v->r < l) return make_pair(0, 1);
    if (v->l >= l && v->r <= r) return v->v;
    return Combine(max(v->left, l, r), max(v->right, l, r));
  }
  pair<long, long> add(Node *v, long i, pair<long, long> p) {
    if (v->IsLeaf()) return v->v = Combine(v->v, p);
    pair<long, long> res;
    if (i <= (v->l + v->r) / 2)
      res = add(v->left, i, p);
    else
      res = add(v->right, i, p);
    v->Update();
    return res;
  }

 public:
  SegmentTree(long l, long r) { root = build(l, r); }
  pair<long, long> Max(long l, long r) { return max(root, l, r); }
  pair<long, long> Add(long i, pair<long, long> p) { return add(root, i, p); }
};
long a[N], l[N][2], c[N][2];
SegmentTree *t[2];
void solve() {
  long n;
  scanf("%ld", &n);
  for (long i = 1; i <= n; ++i) scanf("%ld", a + i);
  long maxlen = 0;
  for (long j = 0; j < 2; ++j) {
    t[j] = new SegmentTree(1, N - 1);
    for (long i = j ? n : 1; j ? i >= 1 : i <= n; j ? --i : ++i) {
      long v = j ? N - a[i] : a[i];
      pair<long, long> mx = t[j]->Max(1, v - 1);
      l[i][j] = mx.first + 1;
      c[i][j] = mx.second;
      t[j]->Add(v, make_pair(mx.first + 1, mx.second));
      Maximize(maxlen, l[i][0]);
    }
  }
  long maxcnt = 0;
  for (long i = 1; i <= n; ++i) {
    if (l[i][0] == maxlen) maxcnt = Plus(maxcnt, c[i][0]);
  }
  for (long i = 1; i <= n; ++i) {
    long res;
    if (l[i][0] + l[i][1] - 1 < maxlen)
      res = 1;
    else if (Mul(c[i][0], c[i][1]) != maxcnt)
      res = 2;
    else
      res = 3;
    printf("%ld", res);
  }
}
void init() {}
int main() {
  init();
  solve();
  return 0;
}
