#include <cstdio>
#include <cstring>
#define buf 1000
using namespace std;
int Search_A(int z);
int Search_B(int z);
int n,cnt,A[50];
int main(void){
  int m,z,i;
  char str[buf],*line;

  for( ;fgets(str,sizeof(str),stdin)!=NULL; ){
      sscanf(str,"%d",&n);
      if(n==0) break;
      fgets(str,sizeof(str),stdin);
      line=strtok(str," ");
      sscanf(line,"%d",&m); A[0]=m;
      for(i=1;i<n;i++){
        line=strtok(NULL," ");
        sscanf(line,"%d",&m);
        A[i]=m;
      }
      z=32; cnt=0;
      while(z!=0){
        z=Search_A(z);
        z=Search_B(z);
      }
  }
  return 0;
}

int Search_A(int z){
  z=z-(z-1)%5;
  if(z<0) z=0;
  printf("%d\n",z);
  return z;
}
int Search_B(int z){
  z=z-A[cnt%n];
  if(z<0) z=0;
  printf("%d\n",z);
  cnt+=1;
  return z;
}