#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 = 2e9;
const int M = (1e9) + 7;
const int N = (1e5) + 1;
int bit[N];
void update(int j, int x) {
  for (; j < N; j += j & (-j)) bit[j] = max(bit[j], x);
}
int query(int j) {
  int x = 0;
  for (; j > 0; j -= (j) & (-j)) x = max(x, bit[j]);
  return x;
}
int cnt[N];
void solve() {
  int n, i, a, x, k;
  scanf("%d", &n);
  vector<int> v(n);
  for (i = 0; i < n; i++) scanf("%d", &v[i]);
  vector<int> fd(n), bd(n);
  for (i = 0; i < n; ++i) {
    a = v[i];
    x = query(a - 1) + 1;
    fd[i] = x;
    update(a, x);
  }
  k = query(N - 1) + 1;
  fill(bit, bit + N, 0);
  for (i = 0; i < n; ++i) v[i] = N - v[i];
  for (i = n - 1; i >= 0; --i) {
    a = v[i];
    x = query(a - 1) + 1;
    bd[i] = x;
    update(a, x);
  }
  vector<int> ans(n, 0);
  for (i = 0; i < n; ++i) {
    if (fd[i] + bd[i] < k)
      ans[i] = 1;
    else
      x = fd[i], cnt[x]++;
  }
  for (i = 0; i < n; ++i) {
    if (fd[i] + bd[i] == k) x = fd[i], ans[i] = 2 + (cnt[x] == 1);
  }
  for (i = 0; i < n; ++i) printf("%d", ans[i]);
  printf("\n");
}
int main() {
  int t = 1;
  while (t--) solve();
}
