#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
vector<pair<long long, long long>> G[N];
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = (0); i < (int)(n); ++i) cin >> a[i];
  vector<int> dp(n + 1, 1e9);
  vector<vector<int>> v(n);
  vector<int> pos(n);
  for (int i = (0); i < (int)(n); ++i) {
    int idx = lower_bound(dp.begin(), dp.end(), a[i]) - dp.begin();
    pos[i] = idx;
    v[idx].push_back(a[i]);
    dp[idx] = a[i];
  }
  vector<int> used(n + 1), cnt(n + 1), maxnum(n + 1);
  maxnum[lower_bound(dp.begin(), dp.end(), 1e8) - dp.begin()] = 1e9;
  for (int i = n - 1; i >= 0; --i) {
    if (maxnum[pos[i] + 1] <= a[i]) continue;
    maxnum[pos[i]] = max(maxnum[pos[i]], a[i]);
    used[i] = 1;
    ++cnt[pos[i]];
  }
  for (int i = (0); i < (int)(n); ++i) {
    if (!used[i])
      cout << 1;
    else if (cnt[pos[i]] > 1)
      cout << 2;
    else
      cout << 3;
  }
  cout << endl;
  return 0;
}
