#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <deque>
#include <cstdio>
#include <cmath>
#include <complex>
#include <iostream>
#include <iterator>

using namespace std;

#define reep(i,f,t) for(int i=f ; i<int(t) ; ++i)
#define rep(i,n) reep(i, 0, n) 

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main()
{
	int n;
	while(scanf("%d", &n), n){
		vi seq(n);
		rep(i, n)
			scanf("%d", &seq[i]);
		
		int oh = 32;
		for(int i=0; oh; ++i){
			if(i%2 == 0)
				oh -= (oh - 1) % 5;
			else
				oh -= min(oh, seq[(i/2)%n]);
			printf("%d\n", oh);
		}
	}
	
	return 0;
}