#include <cstdio>
#include <algorithm>
using namespace std;
#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)

int main(){
    int n;
    while(scanf("%d",&n) && n){
        int r=32;
        int p[40];
        rep(i,n)scanf("%d",p+i);
        rep(i,1000){
            r-=(r-1)%5;
            printf("%d\n",r);
            r-=p[i%n];
            printf("%d\n",max(0,r));
            if(r<0) break;
        }
    }
}