#include <iostream>
using namespace std;

int main()
{
  int i;

  while(cin >> i && i != 0){
    int a[32];
    int n = 32;
    for (int j = 0; j < i; j++){
      cin >> a[j];
    }
    int j = 0;
    while (n > 0){
      n -= (n - 1) % 5;
      cout << n << endl;
      n -= a[j++];
      if (j == i) j = 0;
      if (n < 0) n = 0;
      cout << n << endl;
    }
  }
}