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

int main(void){
	int n,tm;
	while(cin >> n && n){
		vector<int> j;
		int m=31,p=0;
		for(int i=0;i<n;i++){
			cin >> tm;
			j.push_back(tm);
		}
		cout << m << endl;
		while(m){
			m -= j[p];
			if(m<=0){
				cout << 0 << endl;
				break;
			}
			cout << m << endl;
			m -= 5 - j[p++];
			cout << m << endl;
			if(p == j.size()) p=0;
		}
	}
}