#include <bits/stdc++.h>
using namespace std;
int n, f1[100001], f2[100001], h[100001], down[100001], up[100001], l = 0;
pair<int, int> p[100001];
struct inteval {
  int t[100001 * 4];
  void reset() { memset(t, 0, sizeof(t)); }
  int getMax(int l, int r, int id, int x, int y) {
    if (l > y || r < x) return 0;
    if (x <= l && r <= y) return t[id];
    int g = ((l + r) >> 1);
    int a = getMax(l, g, id * 2, x, y);
    int b = getMax(g + 1, r, id * 2 + 1, x, y);
    return max(a, b);
  }
  void update(int l, int r, int id, int x, int w) {
    if (l > x || r < x) return;
    if (l == r) {
      t[id] = w;
      return;
    }
    int g = ((l + r) >> 1);
    update(l, g, id * 2, x, w);
    update(g + 1, r, id * 2 + 1, x, w);
    t[id] = max(t[id * 2], t[id * 2 + 1]);
  }
};
inteval tree;
map<long long, int> Map;
void setup() {
  int id1 = 0, id2 = 1;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> p[i].first;
    p[i].second = i;
  }
  sort(p + 1, p + n + 1);
  for (int i = 1; i <= n; i++) {
    h[p[i].second] = i;
    while (p[id1 + 1].first < p[i].first && id1 <= n) id1++;
    down[p[i].second] = id1;
    while (p[id2].first <= p[i].first && id2 <= n) id2++;
    up[p[i].second] = id2;
  }
}
void chuanbi() {
  tree.reset();
  for (int i = 1; i <= n; i++) {
    int w = tree.getMax(1, n, 1, 1, down[i]);
    f1[i] = w + 1;
    l = max(l, f1[i]);
    tree.update(1, n, 1, h[i], f1[i]);
  }
  tree.reset();
  for (int i = n; i >= 1; i--) {
    int w = tree.getMax(1, n, 1, up[i], n);
    f2[i] = w + 1;
    tree.update(1, n, 1, h[i], f2[i]);
  }
}
void xuly() {
  for (int i = 1; i <= n; i++) {
    long long tem = f1[i] * (n + 1) + f2[i];
    if (Map.find(tem) == Map.end())
      Map[tem] = 1;
    else
      Map[tem]++;
  }
  for (int i = 1; i <= n; i++) {
    if (f1[i] + f2[i] - 1 < l) {
      cout << 1;
      continue;
    }
    long long tem = f1[i] * (n + 1) + f2[i];
    if (Map[tem] > 1)
      cout << 2;
    else
      cout << 3;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  setup();
  chuanbi();
  xuly();
  return 0;
}
