#include<iostream>

using namespace std;

int main()
{
	int n,i,j,num,array[30];
	
	for(;;)
	{
		cin >> n;
		if(n==0)
			break;
		num=32;
		
		for(i=0;i<n;i++)
			cin >> array[i];
		
		for(i=0;num>0;i++)
		{
			num-=(num-1)%5;
			cout << num << endl;
			if(i==n)
				i=0;
			num-=array[i];
			if(num<0)
			cout << "0" << endl;
			else
			cout << num << endl;
		}
	}
}