#include <iostream>
using namespace std;
int n,a[4];

void solve() {
  int step=0,coin=32;
  while(1) {
    if(step % 2 == 0) {
      coin -= (coin-1)%5;
      cout << coin << endl;
      step++;
    }
    else if(step % 2 != 0){
      coin -= a[(step/2) % n];
      if(coin <= 0) {
        cout << "0" << endl;
        break;
      }
      cout << coin << endl;
      step++;
    }
  }
  return;
}

int main() {
  while(cin >> n) {
    if(n==0) break;
    for(int i=0;i<n;i++) {
      cin >> a[i];
    }
    solve();
  }
  return 0;
}