#include <bits/stdc++.h>
using namespace std;
int N, cnt[110000], ok[110000], seg[110000 * 5], dn[110000];
pair<int, int> ar[110000];
int comp(const pair<int, int> &a, const pair<int, int> &b) {
  if (a.first != b.first) return a.first < b.first;
  return a.second > b.second;
}
int find(int k, int b, int e, int a1, int a2) {
  if (b > a2 || e < a1) return INT_MIN;
  if (a1 <= b && e <= a2) return seg[k];
  return max(find(2 * k, b, ((b + e) / 2), a1, a2),
             find(2 * k + 1, ((b + e) / 2) + 1, e, a1, a2));
}
int upd(int k, int b, int e, int a, int t) {
  if (b > a || e < a) return seg[k];
  if (b == e) return seg[k] = t;
  return seg[k] = max(upd(2 * k, b, ((b + e) / 2), a, t),
                      upd(2 * k + 1, ((b + e) / 2) + 1, e, a, t));
}
int main() {
  cin >> N;
  for (int i = 1; i <= N; i++) scanf(" %d", &ar[i].first), ar[i].second = i;
  sort(ar + 1, ar + 1 + N, comp);
  int mx = 0, size = 1;
  for (int i = 1; i <= N; i++) {
    int k = find(1, 1, N, 1, ar[i].second);
    upd(1, 1, N, ar[i].second, k + 1);
    dn[ar[i].second] = k + 1;
    mx = max(mx, k + 1);
  }
  memset(seg, 0, sizeof seg);
  for (int i = N; i; i--) {
    int k = find(1, 1, N, ar[i].second, N);
    upd(1, 1, N, ar[i].second, k + 1);
    if (k + dn[ar[i].second] == mx) {
      ok[ar[i].second] = 1;
      cnt[dn[ar[i].second]]++;
    }
  }
  for (int i = 1; i <= N; i++) {
    if (!ok[i])
      printf("1");
    else if (cnt[dn[i]] >= 2)
      printf("2");
    else
      printf("3");
  }
  return 0;
}
