#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef int INT;
typedef vector<INT> VI;
typedef vector<VI> VVI;
typedef pair <INT, INT> II;
typedef vector <II> VII;

template<class T> ostream& operator << ( ostream& os, vector<T> v ) {
    for ( typename vector<T>::iterator it_i = v.begin(); it_i != v.end(); ++it_i ) {
        os << *it_i << ", ";
    }
    return os;
}


void solve( int n, VI A ) {
    int remain = 32;
    bool flag = true;
    int k = 0;
    while( remain > 0 ) {
        if ( flag ) {
            int take = ( remain - 1 ) % 5;
            remain -= take;
            if ( remain < 0 ) remain = 0;
            cout << remain << endl;
        } else {
            remain -= A[k];
            if ( remain < 0 ) remain = 0;
            cout << remain << endl;
            k = ( k + 1 ) % n;
        }
        flag = !flag;
    }
}

int main() {
    int n;
    while ( cin >> n && n ) {
        VI A(n);
        for ( int i = 0; i < n; ++ i ) cin >> A[i];
        solve( n, A );
    }
    return 0;
}