#include <stdio.h>
#include <stack>
#include <math.h>

using namespace std;

int main(){

	int n,array[25],NUM,index;

	while(true){
		scanf("%d",&n);
		if(n == 0)break;

		for(int i=0; i < n; i++)scanf("%d",&array[i]);

		NUM = 32;
		index = 0;

		while(NUM > 0){
			NUM -= (NUM-1)%5;
			printf("%d\n",NUM);

			NUM -= array[index%n];
			if(NUM <  0){
				printf("0\n");
			}else{
				printf("%d\n",NUM);
			}
			index++;
		}

	}

    return 0;
}