#include <iostream>
using namespace std;
int main(){
	int n;
	while(cin>>n,n){
		int N=32;
		int a[25];
		for(int i=0,an;i<n;++i){
			cin>>an;
			a[i]=an;
		}
		for(int i=0;N;i=(i+1)%n){
			N-=(N-1)%5;
			cout<<N<<"\n";
			N-=a[i];
			if(N<0) N=0;
			cout<<N<<"\n";
		}
	}
	return 0;
}