#include <iostream>
#include <vector>
#include <algorithm>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
	int n;
	while(cin >> n && n)
	{
		vector<int> v;
		rep(i,n)
		{
			int temp;
			cin >> temp;
			v.push_back(temp);
		}

		int o = 32;
		int i = 0;
		while(o > 0)
		{
			o -= (o-1) % 5;

			if(o >= 0) cout << o << endl;
			else cout << 0 << endl;

			if(o == 0) break;
			
			o -= v[i%n];
			i++;

			if(o >= 0) cout << o << endl;
			else cout << 0 << endl;

		}
	}
	return 0;
}