#include <iostream>
#include <vector>

using namespace std;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		vector<int> Vec(n);
		for(int i = 0; i < n; ++i)
		{
			cin >> Vec[i];
		}
		int pos = 0;
		int ohajiki = 32;
		while(ohajiki > 0)
		{
			int temp = (ohajiki - 1) % 5;
			ohajiki -= temp;
			cout << ohajiki << endl;
			if(ohajiki <= Vec[pos])
			{
				ohajiki = 0;
			}
			else
			{
				ohajiki -= Vec[pos];
			}
			pos++;
			if(pos == n)
			{
				pos = 0;
			}
			cout << ohajiki << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}