#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

signed main(){
	int l;
	while(1){
		cin>>l;
		if(l==0) break;
		vi a(l);
		rep(i,0,l) cin>>a[i];
		int n=31;
		o(n);
		rep(i,0,10){
			int tmp=n-a[i%l];
			if(tmp<=0){
				o(0); break;
			}
			o(tmp);
			n-=5;
			o(n);
		}
	}
}