#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

#define rep(i, n)for((i) = 0;(i) < (n);++(i))

int a[30];
int main(void){
	int i, j, n;
	for(;;){
		scanf("%d", &n);
		if(!n)break;
		rep(i, n)scanf("%d", &a[i]);
		j = 0;
		for(int x = 32;x;){
			x -= (x - 1) % 5;
			printf("%d\n", x);
			x = max(0, x - a[j]); j = (j + 1) % n;
			printf("%d\n", x);
		}
	}
}