#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000005;
const long long INFLL = 1000000000000000002ll;
const long long MOD = 1000000007;
inline long long min(long long a, long long b, long long c) {
  return min(min(a, b), c);
}
inline long long min(long long a, long long b, long long c, long long d) {
  return min(min(min(a, b), c), d);
}
inline long long max(long long a, long long b, long long c) {
  return max(max(a, b), c);
}
inline long long max(long long a, long long b, long long c, long long d) {
  return max(max(max(a, b), c), d);
}
bool Not[100005];
int A[100005], Am[100005], B[100005], L[100005], R[100005], N, T[100005];
void update(int x, int v) {
  while (x <= 100000) {
    T[x] = max(T[x], v);
    x += x & -x;
  }
}
int query(int x) {
  int ret = 0;
  while (x > 0) {
    ret = max(ret, T[x]);
    x -= x & -x;
  }
  return ret;
}
void update2(int x, int v) {
  while (x > 0) {
    T[x] = max(T[x], v);
    x -= x & -x;
  }
}
int query2(int x) {
  int ret = 0;
  while (x <= 100000) {
    ret = max(ret, T[x]);
    x += x & -x;
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> N;
  for (int i = (1); i <= (N); i++) cin >> A[i];
  for (int i = (1); i <= (N); i++) {
    int v = A[i];
    int q = query(v - 1);
    L[i] = q + 1;
    update(v, q + 1);
  }
  for (int i = (1); i <= (100000); i++) T[i] = 0;
  for (int i = (N); i >= (1); i--) {
    int v = A[i];
    int q = query2(v + 1);
    R[i] = q + 1;
    update2(v, q + 1);
  }
  int hi = 0;
  for (int i = (1); i <= (N); i++) hi = max(hi, L[i]);
  for (int i = (1); i <= (N); i++) {
    if (L[i] + R[i] == hi + 1)
      B[i] = 3;
    else
      B[i] = 1;
  }
  set<int, greater<int>> s;
  for (int i = (1); i <= (N); i++)
    if (B[i] == 3) {
      if (!s.empty() && *s.begin() >= A[i]) Not[i] = true;
      s.insert(A[i]);
    }
  set<int> s2;
  for (int i = (N); i >= (1); i--)
    if (B[i] == 3) {
      if (!s2.empty() && *s2.begin() <= A[i]) Not[i] = true;
      s2.insert(A[i]);
    }
  for (int i = (1); i <= (N); i++)
    if (Not[i]) B[i] = 2;
  for (int i = (1); i <= (N); i++) cout << B[i];
}
