// tablajatek.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <iostream>
#include <vector>
#include <deque>
using namespace std;
int n, sor, hely, i, a,j;
deque<int>x;
int main()
{
cin >> n;
x.push_back(0);
for (i = 1; i<=n; ++i)
{
cin >> a;
if (a == 0)
{
sor++;
//hely = hely * 2;
x.push_back(0);
}
else if (a == 1)
{
sor++;
//hely = (hely * 2) + 1;
x.push_back(1);
}
else if (a == 2)
{
sor--;
/*if (hely % 2 == 0)
{
hely = hely / 2;
}
else if (hely % 2 != 0)
{
hely = hely - 1;
hely = hely / 2;
}*/
x.pop_back();
}
else if (a == 3)
{
//hely--;
if (x.back() == 1) x.back()=0;
else
{
j = x.size() - 1;
while (x[j] == 0)
{
x[j] = 1;
j--;
}
x[j] = 0;
}
}
else if (a == 4)
{
//hely++;
if (x.back() == 0) x.back()=1;
else
{
j = x.size() - 1;
while (x[j] == 1)
{
x[j] = 0;
j--;
}
x[j] = 1;
}
}
}
while (x.size() > 1 && x.front() == 0) x.pop_front();
/*while (hely / 2)
{
if (hely % 2==0)
{
x.push_front(0);
}
else
{
x.push_front(1);
}
hely = hely / 2;
}
if (hely % 2 == 0) x.push_front(0);
else x.push_front(1);*/
cout << sor << "\n";
for (i = 0; i < x.size(); ++i)
{
cout << x[i];
}
return 0;
}
/*
6
0 1 4 2 1 0
6
0 0 0 0 0 0
*/
// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu
// Tips for Getting Started:
// 1. Use the Solution Explorer window to add/manage files
// 2. Use the Team Explorer window to connect to source control
// 3. Use the Output window to see build output and other messages
// 4. Use the Error List window to view errors
// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file