#include <bits/stdc++.h>
using namespace std;
const int Max = 1e5 + 9, inf = 1e9;
int n, mx, A[Max], dpi[Max], dpd[Max], U[Max], Ans[Max];
vector<int> S;
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> A[i];
  S.push_back(-inf);
  for (int i = 1; i <= n; i++) {
    vector<int>::iterator k = lower_bound(S.begin(), S.end(), A[i]);
    if (k == S.end())
      S.push_back(A[i]), dpi[i] = S.size() - 1;
    else
      S[k - S.begin()] = A[i], dpi[i] = k - S.begin();
    A[i] *= -1;
  }
  S.clear();
  S.push_back(-inf);
  for (int i = n; i >= 1; i--) {
    vector<int>::iterator k = lower_bound(S.begin(), S.end(), A[i]);
    if (k == S.end())
      S.push_back(A[i]), dpd[i] = S.size() - 1;
    else
      S[k - S.begin()] = A[i], dpd[i] = k - S.begin();
  }
  mx = S.size() - 1;
  for (int i = 1; i <= n; i++) {
    if (dpi[i] + dpd[i] - 1 < mx)
      Ans[i] = 1;
    else
      U[dpi[i]]++;
  }
  for (int i = 1; i <= n; i++)
    if (!Ans[i]) Ans[i] = ((U[dpi[i]] == 1) ? 3 : 2);
  for (int i = 1; i <= n; i++) cout << Ans[i];
}
