#include "bits/stdc++.h"
using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define MP(a, b) make_pair(a, b)
#define F first
#define S second
#define INF 1 << 30

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;
using namespace std;
int main(){
  int n,a[30];
  while(1){
    cin >> n;
    if(n==0)break;
    for(int i=0;i<n;i++){
      cin >> a[i];
    }

    int r=32;
    for(int i=0;;i++){
      r -= (r-1) % 5;
      printf("%d\n", r);

      r -= a[i%n];
      if(r<0) r=0;
      printf("%d\n", r);

      if(r==0) break;
    }
  }
}