
#include <stdio.h>
 
int main(){
 
  int i,j,a[26];
  int n,h = 32;
 
 
  while(1) {
    h = 32;
  scanf("%d",&n);
  if(n == 0) break;
 
 
  for(i=0;i<n;i++) scanf("%d",&a[i]);
 
  i = 0;
  while(1) {
 
    h = h -(h-1)%5;
    printf("%d\n",h);
 
 
    h -= a[i%n];
    if(h>0) printf("%d\n",h);
    else {
      printf("0\n");
      break;
    }
 
    i++;
 
  }
   
  }
 
  return 0;
 
}