#include <stdio.h>


int main(void){
    int mbls;
    int len;
    int ary[25], i;
    
    while (scanf("%d", &len)){
        if (len==0) break;
        for (int n=0; n<len; n++){
            scanf("%d", &ary[n]);
        }
        mbls=32;
        i=0;
        while(mbls>0){
            mbls -= (mbls-1)%5;
            printf("%d\n", mbls);
            if (mbls<ary[i]) mbls = 0;
            else mbls -= ary[i];
            printf("%d\n", mbls);
            i = (i+1)%len;
        }
    }
    return 0;
}