#include<cstdio>
using namespace std;
int main(){
    int n;
    while(scanf("%d",&n),n){
        int jiro[32]={0};
        for(int i = 1;i <= n; i++){
            scanf("%d",&jiro[i]);
        }
        bool f = 0;
        int now = 32;
        int x = 0,y = 1;
        int ans[64]={0};
        for(;;){
            if(now <= 0){
                ans[x-1] = 0;
                break;
            }
            if(f == 0){
                now -= (now-1)%5;
                ans[x] = now;
                x++;
                f = 1;
            }
            else if(f == 1){
                int ji;
                (y%n == 0)? ji = jiro[n] : ji = jiro[y%n];
                now -= ji;
                ans[x] = now;
                y++;
                x++;
                f = 0;
            }
        }
        for(int i = 0;i < x; i++)printf("%d\n",ans[i]);
    }
    return 0;
}