#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    int a[n],s=32,p=0;
    for(int i=0;i<n;i++)cin>>a[i];
    while(s){
      s-=(s-1)%5;
      cout<<s<<endl;
      s-=a[p++%n];
      if(s<0)s=0;
      cout<<s<<endl;
    }
  }
}