#include <iostream>
using namespace std;

int a[100];

int main() {
    int n;
    while(cin>>n, n) {
        for(int i=0; i<n; ++i) cin>>a[i];

        int rem = 32,cnt = 0;
        while(rem > 0) {
            rem -= (rem-1)%5;
            cout<<rem<<endl;
            if(rem == 0) break;
            rem -= min(rem,a[cnt%n]);
            cout<<rem<<endl;
            cnt++;
        }
    }
}