#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	int m;
	while(cin >> m , m){
		vector<int> data(m);
		rep(i,m)cin >> data[i];
		int n = 32;
		int lp = 0;
		while(n>0){
			n -= (n-1)%5;
			cout << n << endl;
			n -= data[lp%m];
			cout << (n<0?0:n) << endl;
			lp++;
		}
		
	}
}