#include<iostream>
using namespace std;
int n,a[100];
main()
{
    while(cin>>n,n)
    {
        for(int i=0;i<n;i++)cin>>a[i];
        int c=32,i=0;
        while(c)
        {
            c-=(c-1)%5;
            cout<<c<<endl;
            c-=(a[i]>c?c:a[i]);
            cout<<c<<endl;
            i=(i+1)%n;
        }
    }
}
