#include<iostream>
#include<vector>
using namespace std;

int main()
{
	int n, i, a;
	vector<int> v(25);
	int o;
	while (cin>>n, n) {
		for (i = 0; i < n; i++) {
			cin>>a;
			v[i] = a;
		}
		o = 31;
		cout<<o<<endl;
		for (i = 0; o > 0; i++) {
			o -= v[i%n];
			if (o<0) o = 0;
			cout<<o<<endl;
			if (o==0) break;
			o -= (o-1)%5;
			cout<<o<<endl;
		}
	}
	return 0;
}