#include <bits/stdc++.h>
using namespace std;
int AA[100001];
int LL[100001];
int RR[100001];
int TT[100001];
int ans[100001];
int input;
int mx = -1;
vector<int> Last;
int LIS(int A[], int L[]);
int main() {
  cin >> input;
  for (int i = 1; i <= input; i++) {
    cin >> AA[i];
    ans[i] = 1;
  }
  LIS(AA, LL);
  Last.clear();
  for (int i = 1; i <= input; i++) {
    RR[i] = 100000 - AA[i];
  }
  for (int i = 1; i <= input; i++) {
    TT[i] = RR[input - i + 1];
  }
  LIS(TT, RR);
  for (int i = 1; i <= input; i++) {
    if (LL[i] + RR[input - i + 1] == mx + 1) ans[i] = 3;
  }
  int cmx = -1, cmn = 100005;
  for (int i = 1; i <= input; i++) {
    if (ans[i] != 1) {
      if (AA[i] <= cmx) ans[i] = 2;
      cmx = max(cmx, AA[i]);
    }
  }
  for (int i = input; i >= 1; i--) {
    if (ans[i] != 1) {
      if (AA[i] >= cmn) ans[i] = 2;
      cmn = min(cmn, AA[i]);
    }
  }
  for (int i = 1; i <= input; i++) {
    cout << ans[i];
  }
  cout << endl;
  return 0;
}
int LIS(int A[], int L[]) {
  vector<int>::iterator it;
  Last.push_back(-100);
  for (int i = 1; i <= input; i++) {
    if (Last.back() < A[i]) Last.push_back(A[i]);
    it = lower_bound(Last.begin(), Last.end(), A[i]);
    *it = A[i];
    L[i] = it - Last.begin();
    if (mx < L[i]) mx = L[i];
  }
  return 0;
}
