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

int main() {
	int n, num, turn;
	vector< int > sq;
	
	while(cin >> n, n){
		sq.resize(n);
		for(int i = 0; i < n; ++i) cin >> sq[i];
		
		num = 32;
		turn = 1;
		
		while(num > 0){
			if(turn % 2){
				num -= (num - 1) % 5;
			}else{
				num -= (sq[(turn / 2 - 1) % n]);
				if(num < 0) num = 0;
			}
			++turn;
			
			cout << num << endl;
		}
	}
	return 0;
}