#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005, mod = 1e9 + 7;
int n, a[maxn];
pair<int, long long> bit[maxn], tot;
pair<int, long long> dp[3][maxn];
inline void upd(int p, pair<int, long long> v) {
  for (int i = p; i <= 1e5; i += i & -i) {
    if (v.first > bit[i].first)
      bit[i] = v;
    else if (v.first == bit[i].first)
      bit[i].second = (bit[i].second + v.second) % mod;
  }
}
inline pair<int, long long> qu(int p) {
  int mm = 0;
  for (int i = p; i > 0; i -= i & -i) mm = max(mm, bit[i].first);
  long long r = 0;
  for (int i = p; i > 0; i -= i & -i) {
    if (bit[i].first == mm) r = (r + bit[i].second) % mod;
  }
  return make_pair(mm, r);
}
void solve(int (&a)[maxn], pair<int, long long> (&dp)[maxn]) {
  memset(bit, 0, sizeof bit);
  upd(1, make_pair(0, 1));
  for (int i = 1; i <= n; i++) {
    pair<int, long long> nxt = qu(a[i]);
    dp[i] = make_pair(nxt.first + 1, nxt.second);
    upd(a[i] + 1, dp[i]);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf(" %d", &a[i]);
  solve(a, dp[0]);
  for (int i = 1; i <= n; i++) {
    if (dp[0][i].first > tot.first)
      tot = dp[0][i];
    else if (dp[0][i].first == tot.first)
      tot.second = (tot.second + dp[0][i].second) % mod;
  }
  solve(a, dp[1]);
  for (int i = 1; i <= n; i++) a[i] = 1e5 + 1 - a[i];
  reverse(a + 1, a + n + 1);
  solve(a, dp[2]);
  for (int i = 1; i <= n; i++) {
    pair<int, long long> f = dp[1][i], s = dp[2][n - i + 1];
    if (f.first + s.first - 1 != tot.first)
      printf("1");
    else if ((f.second * s.second) % mod != tot.second)
      printf("2");
    else
      printf("3");
  }
}
