#include<bits/stdc++.h>
using namespace std;
typedef long long int lld;

int main(){
  int n;
  while(cin >> n ,n){
    int num[100];
    for(int i=0;i<n;i++){
      cin >> num[i];
    }
    int now = 32;
    int idx = 0;
    while(now != 0){
      if(idx % 2 == 0){
	now = max(0,now-(now-1)%5);
      } else {
	now = max(0,now-num[(idx/2)%n]);
      }
      cout << now << endl;
      idx++;
    }
  }
}