#include <bits/stdc++.h>
using namespace std;
const int dl = 1e9 + 7;
const int M = 1e5 + 10;
const int INF = 1e9;
int a[M];
int dp1[M];
int dp2[M];
int pos1[M];
int pos2[M];
int cnt[M];
int ans[M];
int n;
int len;
int main() {
  cin >> n;
  for (int i = 0; i < (int)n; i++) cin >> a[i];
  dp1[0] = -INF;
  dp2[0] = INF;
  for (int i = 1; i <= n; i++) dp1[i] = INF, dp2[i] = -INF;
  for (int i = 0; i < n; i++) {
    int l = 0, r = n + 1;
    while (r - l > 1) {
      int mid = (r + l) / 2;
      if (dp1[mid] < a[i])
        l = mid;
      else
        r = mid;
    }
    dp1[l + 1] = a[i];
    len = max(len, l + 1);
    pos1[i] = l + 1;
  }
  for (int i = n - 1; i >= 0; i--) {
    int l = 0, r = n + 1;
    while (r - l > 1) {
      int mid = (r + l) / 2;
      if (dp2[mid] > a[i])
        l = mid;
      else
        r = mid;
    }
    dp2[l + 1] = a[i];
    pos2[i] = l + 1;
  }
  for (int i = 0; i < n; i++) {
    if (pos1[i] + pos2[i] - 1 == len) {
      ans[i] = 1;
      cnt[pos1[i]]++;
    }
  }
  for (int i = 0; i < n; i++) {
    if (pos1[i] + pos2[i] - 1 == len && cnt[pos1[i]] == 1) ans[i]++;
  }
  for (int i = 0; i < n; i++) cout << ans[i] + 1;
  return 0;
}
