#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int main(){
  int n;
  while(cin >> n, n){
    int seq[30];
    
    for(int i = 0 ; i < n ; i++){
      cin >> seq[i];
    }
    
    int r = 32;
    int i = 0;
    while(1){
      if(r <= 0) break;
      r -= (r-1)%5;
      cout << r << endl;
      r -= seq[i];
      if(r <= 0) r = 0;
      cout << r << endl;
      i++;
      if(i == n) i = 0;
    }
  }
  return 0;
}