#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    int toru[n];
    int ohajiki=32;
    int cnt=0;
    for(int i=0;i<n;i++)
      cin>>toru[i];
    while(ohajiki!=0){
      if(cnt%2==0){
	ohajiki-=(ohajiki-1)%5;
	cnt++;
	if(ohajiki<0)
	  ohajiki=0;
	cout<<ohajiki<<endl;
      }else{
	ohajiki-=toru[(cnt/2)%n];
	//cout<<toru[(cnt/2)%n]<<endl;
	cnt++;
	if(ohajiki<0)
	  ohajiki=0;
	cout<<ohajiki<<endl;
      }
    }
  }
  return 0;
}