#include <iostream>
#include <cstdlib>

using namespace std;
const static int O_NUM = 32; 
const static int I_MAX = 25;
int main() {
  while( 1 ) {
    int n, i, lis[ I_MAX ];
    cin >> i;
    if( !i ) { return EXIT_SUCCESS; }
    for( int j = 0; j < i; j++ ) {
      cin >> lis[ j ];
    }
    n = O_NUM;
    for( int j = 0; n > 0; j++ ) {
      if( !( j % 2 ) ) {
        n -= ( n - 1 ) % 5;
      } else {
        n -= lis[ j / 2 % i ];
      }
      n = max( 0, n );
      cout << n << endl;
    }
  }
}