#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int n, a[30];
    while(cin >> n, n){
        int sum = 32;
        rep(i,n){
            cin >> a[i];
        }
        int i = 0;
        while(sum){
            sum -= (sum - 1) % 5;
            cout << sum << endl;
            sum-= a[i % n];
            sum = sum < 0 ? 0 : sum;
            cout << sum << endl;
            i++;
        }
    }
}