#include <iostream>
#include <algorithm>
using namespace std;

int n, arr[25];

int main(void){
  while(cin >> n && n != 0){
    for(int i = 0; i < n; i++) cin >> arr[i];
    int ohajiki = 32, i = 0;
    while(ohajiki != 0){
      ohajiki -= (ohajiki - 1) % 5;
      cout << ohajiki << endl;
      ohajiki = max(ohajiki - arr[i % n], 0);
      cout << ohajiki << endl;
      i++;
    }
  }
  return 0;
}