#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#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()
#define INF 1<<30

int main() {
  int n;
  while(cin>>n,n) {
    int a[n];
    REP(i,n)
      cin >> a[i];
    int b = 32;
    int ct = 0;
    while(b>0) {
      b -= (b-1)%5;             // ツ暗ェツ郎
      cout << b << endl;
      b = max(0,b-a[(ct++)%n]);
      cout << b << endl;
    }
  }
}