#include <iostream>
using namespace std;

int main(void){
	int n,x[25];

	while(cin>>n && n){
		for(int i=0;i<n;i++) cin>>x[i];

		int rem = 32, k=0;
		for(int j=0;rem > 0;j++){
			if(j % 2 == 0){
				rem -= (rem - 1) % 5;
			}
			else{
				rem -= x[k];
				if(rem < 0) rem = 0;
				k = (k + 1) % n;
			}
			cout<<rem<<endl;
		}
	}

	return 0;
}