#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 ohajiki = 32;
		bool endFlag = false;
		int pos = 0;
		while(!endFlag)
		{
			ohajiki -= (ohajiki - 1) % 5;
			cout << ohajiki << endl;
			ohajiki -= Vec[pos];
			++pos;
			if(pos >= n)
			{
				pos = 0;
			}
			if(ohajiki <= 0)
			{
				endFlag = true;
				cout << 0 << endl;
				continue;
			}
			else
			{
				cout << ohajiki << endl;
			}
		}
	}
}

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