#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<list>
#include<stack>
#include<queue>
#include<cctype>
#include<iomanip>
#include<functional>
#include<numeric>
#include<map>
#include<set>
#include<complex>
#define EPS 1e-10
using namespace std;
typedef long long llong;
int main() {

	int n;
	while (cin >> n, n) {
		vector<int>v(n);
		for (int i = 0; i < n; i++)cin >> v[i];
		int x = 0;
		int value = 32;
		while (1) {
			value -= (value - 1) % 5;
			cout << value << endl;
			if (value == 1) {
				cout << 0 << endl;
				break;
			}
			value -= v[(x++) % n];
			cout << value << endl;
		}

		
	}

	return 0;
}