#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimization("unrolled-loops")
using namespace std;
const unsigned long long mod = 998244353;
const long long mod2 = 1e9 + 9;
const long long INF = 2e9 + 7;
const double eps = 1e-8;
int test = 1;
void FlyingTuna() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ifstream *fi = new ifstream(
      "TestCode"
      ".inp");
  ofstream *fo = new ofstream(
      "TestCode"
      ".out");
  if (*fi) {
    cin.rdbuf(fi->rdbuf());
    cout.rdbuf(fo->rdbuf());
  }
}
inline int ReadInt() {
  char c;
  while (c = getchar(), c < '0' || c > '9')
    ;
  int x = c - '0';
  while (c = getchar(), c >= '0' && c <= '9') x = x * 10 + c - '0';
  return x;
}
inline char ReadCh() {
  char c;
  while (c = getchar(), c < 'A' || c > 'Z')
    ;
  return c;
}
void WriteInt(int x) {
  if (x > 9) WriteInt(x / 10);
  putchar(x % 10 + '0');
}
int n;
int a[100010];
int L1[100010], L2[100010];
int t1[100010], t2[100010];
int sl[100010];
int MAX = 0;
void update1(int id, int v) {
  while (id >= 1) {
    t1[id] = max(t1[id], v);
    id = id - (id & (-id));
  }
}
int get1(int id) {
  int ans = 0;
  while (id <= MAX) {
    ans = max(ans, t1[id]);
    id = id + (id & (-id));
  }
  return ans;
}
void update2(int id, int v) {
  while (id <= MAX) {
    t2[id] = max(t2[id], v);
    id = id + (id & (-id));
  }
}
int get2(int id) {
  int ans = 0;
  while (id >= 1) {
    ans = max(ans, t2[id]);
    id = id - (id & (-id));
  }
  return ans;
}
void In() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i], MAX = max(MAX, a[i]);
}
void Solve() {
  In();
  int lis = 0;
  for (int i = 1; i <= n; i++) {
    L1[i] = get2(a[i]) + 1;
    update2(a[i] + 1, L1[i]);
    lis = max(lis, L1[i]);
  }
  for (int i = n; i >= 1; i--) {
    L2[i] = get1(a[i]) + 1;
    update1(a[i] - 1, L2[i]);
  }
  for (int i = 1; i <= n; i++) {
    if (L1[i] + L2[i] - 1 < lis) continue;
    sl[L1[i]]++;
  }
  for (int i = 1; i <= n; i++) {
    if (L1[i] + L2[i] - 1 < lis) {
      cout << 1;
      continue;
    }
    if (sl[L1[i]] == 1)
      cout << 3;
    else
      cout << 2;
  }
}
int32_t main() {
  FlyingTuna();
  while (test--) Solve();
}
