#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define INF (1<<20)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

int main()
{
	int n;
	while (cin >> n, n) {
		int a[30];
		rep(i, n) cin >> a[i];

		int ohajiki = 32,idx = 0;
		while (ohajiki > 0) {
			ohajiki -= (ohajiki - 1) % 5;
			cout << ohajiki << endl;
			if (ohajiki - a[(idx + n) % n] < 0)
				ohajiki = 0;
			else
				ohajiki -= a[(idx + n) % n];
			idx++;
			cout << ohajiki << endl;
		}
	}
	return 0;
}