#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int a[100];

int main(){
	
	while(true){
		
		int n;
		
		cin >> n;
		
		if(n == 0){
			break;
		}
		
		for(int i = 0; i < n; i++){
			cin >> a[i];
		}
		
		int index = 0;
		int rest = 31;
		
		while(true){
			cout << rest << endl;
			if(rest - a[index] <= 0){
				cout << "0" << endl;
				break;
			}
			cout << rest - a[index] << endl;
			index++;
			if(index >= n){
				index = 0;
			}
			rest -= 5;
		}
		
	}
	return 0;
}