#include <bits/stdc++.h>
using namespace std;
int a[100107], c[100107], n, MAX;
int dp1[100107], dp2[100107];
string S;
int lowbit(int x) { return x & -x; }
void modify(int up, int x, int val) {
  if (up) {
    while (x <= MAX) {
      c[x] = max(c[x], val);
      x += lowbit(x);
    }
  } else {
    while (x > 0) {
      c[x] = max(c[x], val);
      x -= lowbit(x);
    }
  }
}
int getmax(int up, int x) {
  int maxi = 0;
  if (up) {
    while (x > 0) {
      maxi = max(maxi, c[x]);
      x -= lowbit(x);
    }
  } else {
    while (x <= MAX) {
      maxi = max(maxi, c[x]);
      x += lowbit(x);
    }
  }
  return maxi;
}
map<int, int> mp;
int main() {
  int i, j;
  while (scanf("%d", &n) != EOF) {
    S = "#";
    MAX = 0;
    for (i = 1; i <= n; i++) cin >> a[i], S += "0", MAX = max(MAX, a[i]);
    memset(c, 0, sizeof(c));
    int LIS = 0;
    for (i = 1; i <= n; i++) {
      int maxi = getmax(1, a[i] - 1);
      dp1[i] = maxi + 1;
      LIS = max(LIS, dp1[i]);
      modify(1, a[i], dp1[i]);
    }
    memset(c, 0, sizeof(c));
    for (i = n; i >= 1; i--) {
      int maxi = getmax(0, a[i] + 1);
      dp2[i] = maxi + 1;
      modify(0, a[i], dp2[i]);
    }
    mp.clear();
    for (i = 1; i <= n; i++) {
      if (dp1[i] + dp2[i] - 1 != LIS)
        S[i] = '1';
      else
        mp[dp1[i]]++;
    }
    for (i = 1; i <= n; i++)
      if (S[i] != '1' && mp[dp1[i]] == 1) S[i] = '3';
    for (i = 1; i <= n; i++)
      if (S[i] == '0') S[i] = '2';
    cout << S.substr(1, n) << endl;
  }
  return 0;
}
