#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int m;
        cin >> m;
        if(m == 0)
            return 0;
        vector<int> a(m);
        for(int i=0; i<m; ++i)
            cin >> a[i];

        int n = 32;
        for(int i=0; ; (++i)%=m){
            n -= (n - 1) % 5;
            cout << n << endl;

            n -= a[i];
            n = max(n, 0);
            cout << n << endl;
            if(n == 0)
                break;
        }
    }
}