#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
const long long MOD = 1000000007;
const int INF = 0x3f3f3f3f;
int dp[N], a[N];
int f[N], g[N];
int cnt[N];
int lcs(int n, int *f) {
  fill(dp, dp + n, INF);
  for (int i = 0; i < n; i++) {
    int pos = lower_bound(dp, dp + n, a[i]) - dp;
    dp[pos] = a[i];
    f[i] = pos + 1;
  }
  return lower_bound(dp, dp + n, INF) - dp;
}
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  while (cin >> n) {
    for (int i = 0; i < n; i++) cin >> a[i];
    int len = lcs(n, f);
    reverse(a, a + n);
    for (int i = 0; i < n; i++) a[i] = -a[i];
    lcs(n, g);
    reverse(g, g + n);
    string ret(n, '1');
    memset(cnt, 0, sizeof cnt);
    for (int i = 0; i < n; i++) {
      if (f[i] + g[i] - 1 == len) {
        ret[i] = '2';
        cnt[f[i]]++;
      }
    }
    for (int i = 0; i < n; i++) {
      if (f[i] + g[i] - 1 == len && cnt[f[i]] == 1) {
        ret[i] = '3';
      }
    }
    cout << ret << endl;
  }
  return 0;
}
