#include <bits/stdc++.h>
const int maxn = 1e5 + 7;
class TreeArray {
 private:
  int arr[maxn], n;
  int Lowbit(int x) { return x & (-x); }

 public:
  void Init(int x) {
    n = x;
    memset(arr, 0, sizeof(arr));
  }
  void AddVal(int pos, int val, int op) {
    if (op == 0) {
      while (pos) {
        arr[pos] = std ::max(arr[pos], val);
        pos -= Lowbit(pos);
      }
    } else {
      while (pos <= n) {
        arr[pos] = std ::max(arr[pos], val);
        pos += Lowbit(pos);
      }
    }
  }
  int Query(int pos, int op) {
    if (!pos) {
      return 0;
    }
    int res = 0;
    if (op == 0) {
      while (pos <= n) {
        res = std ::max(res, arr[pos]);
        pos += Lowbit(pos);
      }
    } else {
      while (pos) {
        res = std ::max(res, arr[pos]);
        pos -= Lowbit(pos);
      }
    }
    return res;
  }
};
class Solution {
 private:
  int n, a[maxn], start[maxn], end[maxn], ans, maxx, sum[maxn];
  TreeArray tree;
  char res[maxn];

 public:
  Solution() {
    Get();
    Solve();
  }
  void Get() {
    scanf("%d", &n);
    for (register int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      maxx = std ::max(maxx, a[i]);
    }
  }
  void Solve() {
    tree.Init(maxx);
    for (register int i = 1; i <= n; i++) {
      end[i] = tree.Query(a[i], 1) + 1;
      ans = std ::max(ans, end[i]);
      tree.AddVal(a[i] + 1, end[i], 1);
    }
    tree.Init(maxx);
    for (register int i = n; i >= 1; i--) {
      start[i] = tree.Query(a[i] + 1, 0) + 1;
      tree.AddVal(a[i], start[i], 0);
    }
    for (register int i = 1; i <= n; i++) {
      if (start[i] + end[i] <= ans) {
        res[i - 1] = '1';
        continue;
      }
      res[i - 1] = '2';
      sum[start[i]]++;
    }
    for (register int i = 1; i <= n; i++) {
      if (res[i - 1] == '1') {
        continue;
      }
      if (sum[start[i]] == 1) {
        res[i - 1] = '3';
      }
    }
    puts(res);
  }
};
Solution sol;
int main() {}
