// AOJ 0164
#include <iostream>
#include <vector>
#include <cstdio>

using namespace std;

int main()
{
	int n;
	while (scanf("%d", &n) != EOF){
		vector <int> kotori(n);
		int kotori_cnt = 0, honoka = 32;
		for (int i = 0; i < n; i++){
			cin >> kotori[i];
		}
		while (honoka > 0){
			honoka = honoka - ((honoka - 1) % 5);
			cout << honoka << endl;
				// kotori
			honoka -= (kotori[kotori_cnt % n]);
			// cout << "*** DEBUG " << kotori_cnt << endl;
			kotori_cnt++;
			if (honoka <= 0) break;
			cout << honoka << endl;
		}
		cout << 0 << endl;
	}

	return 0;
}