#include<cstdio>
using namespace std;
int main(){
    while(1){
        int n;
        scanf("%d",&n);
        if(n == 0) break;
        int a[30] = {0};
        for(int i = 0; i < n; i++){
            scanf("%d",&a[i]);
        }
        int now = 32;
        for(int i = 0; now != 0; i++){
            if(i % 2 == 0) now -= (now-1)%5;
            else now -= a[(i/2)%n];
            now = (now < 0) ? 0:now;
            printf("%d\n",now);
        }
    }

    return 0;
}