#include <iostream>
using namespace std;

int main(){
	int n;
	int a[30];

	while( cin >> n , n ){
		for(int i=0 ; i<n ; ++i ){
			cin >> a[i];
		}
		int m = 32;
		
		for(int i=0 ; m ; ++i ){
			m -= (m-1)%5;
			m = (m<0)? 0 : m ;
			cout << m << endl;
			if(!m) break;
			m -= a[i%n];
			m = (m<0)? 0 : m ;
			cout << m << endl;
		}
	}
}