//#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<algorithm>
//#include<cmath>
//#include<string>
//#include<cctype>
//#include <vector>
using namespace std;
int main() {
	int n;
	while (cin >>n, n) {
		int a[25] = {};
		int i=0, s = 32;
		while(i<n) cin >> a[i++];
		i = 0;
		while (s>0) {
			s -= (s - 1) % 5;
			cout << s << endl;
			s -= a[i++%n];
			cout << max(0,s) << endl;
		}
	}
	return 0;
}