#include <bits/stdc++.h>
using namespace std;
int n;
int arr[100001];
int rev_arr[100001];
int LIS[100001];
int DLIS[100001];
int all_cnt[100001];
int sum[1000001];
int ans[100001];
int MAX_LEN = -1;
vector<int> len;
vector<int> dlen;
int bs(int x) {
  int l = 1;
  int r = len.size() - 1;
  int ch = 0;
  while (l < r) {
    int mid = (l + r) / 2;
    if (x <= len[mid])
      r = mid;
    else
      l = mid + 1;
  }
  len[l] = x;
  return l;
}
int rbs(int x) {
  int l = 1;
  int r = dlen.size() - 1;
  int ch = 0;
  while (l < r) {
    int mid = (l + r) / 2;
    if (x <= dlen[mid])
      r = mid;
    else
      l = mid + 1;
  }
  dlen[l] = x;
  return l;
}
void printLen() {
  cout << endl;
  for (int i = 0; i < len.size(); i++) {
    cout << len[i] << " ";
  }
  cout << endl;
}
void getLIS() {
  len.push_back(-100);
  LIS[0] = 0;
  for (int i = 1; i <= n; i++) {
    if (len.back() < arr[i]) {
      len.push_back(arr[i]);
      LIS[i] = len.size() - 1;
    } else
      LIS[i] = bs(arr[i]);
    MAX_LEN = max(MAX_LEN, (int)len.size() - 1);
  }
}
void getDLIS() {
  dlen.push_back(-100);
  DLIS[0] = 0;
  for (int i = 1; i <= n; i++) {
    if (dlen.back() < rev_arr[i]) {
      dlen.push_back(rev_arr[i]);
      DLIS[i] = dlen.size() - 1;
    } else
      DLIS[i] = rbs(rev_arr[i]);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &arr[i]);
    rev_arr[n - i + 1] = 100000 - arr[i];
  }
  getLIS();
  getDLIS();
  int i = 1, tmp;
  while (i <= n / 2) {
    tmp = DLIS[i];
    DLIS[i] = DLIS[n - i + 1];
    DLIS[n - i + 1] = tmp;
    i++;
  }
  int maxSum = -1;
  for (int i = 1; i <= n; i++) {
    sum[i] = LIS[i] + DLIS[i];
    maxSum = max(maxSum, sum[i]);
  }
  int maxi = -1;
  for (int i = 1; i <= n; i++) {
    if (sum[i] != maxSum) {
      ans[i] = 1;
    } else {
      if (arr[i] <= maxi) ans[i] = 2;
      maxi = max(maxi, arr[i]);
    }
  }
  int mini = 100001;
  for (int i = n; i > 0; i--) {
    if (ans[i] != 1) {
      if (arr[i] >= mini)
        ans[i] = 2;
      else if (ans[i] == 0) {
        ans[i] = 3;
      }
      mini = min(mini, arr[i]);
    }
  }
  for (int i = 1; i <= n; i++) printf("%d", ans[i]);
  return 0;
}
