#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << "\n";
  err(++it, args...);
}
const double PI = acos(-1);
const double eps = (1e-9);
const long long int INF = 2e18;
const int M = (1e9) + 7;
const int N = (4e5) + 3;
const int K = 20;
vector<int> longest(vector<int> &v) {
  int i, j, n = (int)v.size();
  vector<int> val;
  vector<int> lis(n);
  val.emplace_back(-M);
  int x = 0;
  for (i = 0; i < n; ++i) {
    if (v[i] > val.back())
      val.emplace_back(v[i]), lis[i] = ++x;
    else {
      j = lower_bound(val.begin(), val.end(), v[i]) - val.begin();
      val[j] = v[i];
      lis[i] = j;
    }
  }
  return lis;
}
void solve() {
  int i, n;
  scanf("%d", &n);
  vector<int> v(n);
  for (i = 0; i < n; i++) scanf("%d", &v[i]);
  auto lis = longest(v);
  reverse(v.begin(), v.end());
  for (i = 0; i < n; ++i) v[i] = -v[i];
  auto lds = longest(v);
  reverse(lds.begin(), lds.end());
  vector<int> cnt(n + 1, 0);
  vector<int> ans(n, 1);
  int m = *(max_element(lis.begin(), lis.end()));
  for (i = 0; i < n; ++i) {
    if (lis[i] + lds[i] == m + 1) cnt[lis[i]]++;
  }
  for (i = 0; i < n; ++i) {
    if (lis[i] + lds[i] == m + 1) ans[i] = 2 + (cnt[lis[i]] == 1);
  }
  for (i = 0; i < n; ++i) printf("%d", ans[i]);
  printf("\n");
}
int main() {
  int t = 1;
  while (t--) solve();
}
