#include <iostream>
#include <vector>
//#include <fstream>

using namespace std;

int main()
{
//	cut here before submit 
//	freopen ("testcase.ohajiki", "r", stdin );
	int n;

	while (1) {
		cin >> n;

		if (n == 0 ){
			break;
		} // end if

		vector <int> a (n, 0 );
		int i;

		for (i = 0; i < n; ++i){
			cin >> a[i];
		} // end for
		int ohajiki = 32;
		i = 0;		
	
		while (ohajiki > 0 ){
			int taro = (ohajiki - 1 ) % 5;
			ohajiki -= taro;
			cout << ohajiki << endl;
			int jiro = min (a[i], ohajiki );
			ohajiki -= jiro;
			cout << ohajiki << endl;
			i = (i + 1) % n;
		} // end while
	} // end loop
		
	return 0;
}