#include <bits/stdc++.h>
using namespace std;

long long posLookup(long long arr[][2], long long n, long long size_arr) {
    for(long long i = 0; i < size_arr; i++) {
        if (arr[i][0] == n  && arr[i][1])
            return 1;
    }
    return 0;
}
long long posIndexLookup(long long arr[][2], long long n, long long size_arr) {
    for(long long i = 0; i < size_arr; i++) {
        if (arr[i][0] == n  && arr[i][1])
            return i;
    }
    return 0;
}
long long behindX(long long arr[][2], long long x, long long size_arr){
    long long closest = 0;
    for(long long i = 0; i < size_arr; i++) {
        if (arr[i][0] < closest  && arr[i][1])
            closest = arr[i][0];
    }
    return closest;
}
long long inFrontOfX(long long arr[][2], long long x, long long size_arr){
    long long closest = 0;
    for(long long i = 0; i < size_arr; i++) {
        if (arr[i][0] >= closest && arr[i][1])
            closest = arr[i][0];
    }
    return closest;
}

int main() {
    long long n;
    cin >> n;
    long long dementor_pos[n][2];
    long long player_pos = 0;
    vector<long long> moves = {};
    long long dementor_eliminated = 0;
    for(long long i = 0; i < n; i++) {
        long long p;
        cin >> p;
        dementor_pos[i][0] = p;
        dementor_pos[i][1] = 1;
    }

    long long last_move = 10;
    long long ziv = 1;
    while(ziv) {
        if(posLookup(dementor_pos, player_pos+1, n) && last_move != 1){
            last_move = 1;
            dementor_pos[player_pos+1][1] = 0;
            dementor_eliminated++;
        } else if(posLookup(dementor_pos, player_pos+1, n) && last_move == 1){
            ziv = 0;
            break;
        } else if(posLookup(dementor_pos, player_pos-1, n) && last_move != 2){
            last_move = 2;
            dementor_pos[player_pos-1][1] = 0;
            dementor_eliminated++;
        } else if(posLookup(dementor_pos, player_pos-1, n) && last_move == 2){
            last_move = 3;
            player_pos++;
        } else if (long long closest_behind = behindX(dementor_pos, player_pos, n) && last_move != 2) {
            last_move = 2;
            dementor_pos[posIndexLookup(dementor_pos, closest_behind, n)][1] = 0;
            dementor_eliminated++;
        } else if (long long closest_front = inFrontOfX(dementor_pos, player_pos, n) && last_move != 1) {
            last_move = 1;
            dementor_pos[posIndexLookup(dementor_pos, closest_front, n)][1] = 0;
            dementor_eliminated++;
        } else {
            last_move = 3;
            player_pos++;
        }


        moves.push_back(last_move);
        for(long long i = 0; i < n; i++) {
            if (dementor_pos[i][0] < player_pos){
                dementor_pos[i][0]++;
            }
            else
                dementor_pos[i][0]--;
        }

        if(dementor_eliminated == n){
            ziv = 0;
        }
    }

    cout << dementor_eliminated << endl;
    for(long long i = 0; i < moves.size(); i++) {
        cout << moves[i];
    }


}