#include <iostream>
using namespace std;
int a[26];
int main()
{
  int i,j,k,r;
  for(;;){
    cin >> i;
    if(i==0)break;
    for(j=0;j<i;j++){
      cin >> a[j];
    }
    r = 32;
    j = 0;
    while(r > 0){
      r -= (r - 1) % 5;
      cout << r << endl;
      r -= a[j++];
      if(i==j) j = 0;
      if(r < 0) r = 0;
      cout << r << endl;
    }
  }
  return 0;
}