#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

int main(){
  int n;
  while(cin>>n, n){
    int j[n];
    int r = 32;
    int rr = 0;
    REP(i,n) cin>>j[i];
    while(r > 0){
      r -= (r-1)%5;
      cout << r << endl;
      r -= j[(rr++)%n];
      if(r < 0) r = 0;
      cout << r << endl;
    }
  }
  return 0;
}