#include <iostream>

using namespace std;

int main()
{
    int n;
    
    while (cin >> n, n) {
        int res = 32;
        int jirou[25];
        int cnt = 0;

        for (int i = 0; i < n; i++)
            cin >> jirou[i];

        while (true) {
            res -= (res - 1) % 5;
            cout << res << endl;

            res -= jirou[cnt];
            cnt = (cnt + 1) % n;
            if (res < 1) {
                cout << 0 << endl;
                break;
            }
            
            cout << res << endl;
        }
    }

    return 0;
}