#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main()
{
  int i;
  for(;cin>>i,i;)
    {
      int count=32;
      int a[i];
      for(int j=0;j<i;j++)
	  cin>>a[j]; 
      for(int x=0;count!=0;x++)
	{
	  count-=(count-1)%5;
	  cout<<count<<endl;
	  count-=a[x%i];
	  if(count<0)
	    count=0;
	  cout<<count<<endl;
	}
    }
}