#include <iostream>
using namespace std;

int main()
{
	int n;
	while( cin >> n && n ){
		int pickup[ 25 ] = {0};
		for( int i = 0; i < n; ++i ){
			cin >> pickup[ i ];
		}
		int stone = 32;
		int turn = 0;
		while( stone > 0 ){
			if( turn % 2 ){
				stone -= pickup[ ( turn / 2 ) % n ];
			}else{
				stone -= ( ( stone - 1 ) % 5 );
			}
			if( stone < 0 ){
				stone = 0;
			}
			cout << stone << endl;
			++turn;
		}
	}

	return 0;
}