#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int MAXA = 26;

int a[MAXA];

int main()
{
    int n, j, now;
    while(cin >> j && j)
    {
        REP(j) cin >> a[i];
        
        n = 32; now = 0;
        while(n)
        {
            n -= (n - 1) % 5;
            cout << n << endl;
            
            if(n - a[now] <= 0){cout << 0 << endl; break;}
            n -= a[now];
            cout << n << endl;
            now = (now + 1 ) % j;
        }

    }

    return 0;
}