Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		n, _ := strconv.Atoi(scanner.Text())
		if n == 0 {
			break
		}
		scanner.Scan()
		buf := strings.Split(scanner.Text(), " ")
		input := make([]int, len(buf))
		for i := range input {
			input[i], _ = strconv.Atoi(buf[i])
		}
		fmt.Println(31)
		i, k := 0, 31
		for k > 1 {
			k -= input[i]
			fmt.Println(k)
			k = k - (k-1)%5
			fmt.Println(k)
			i++
			if i >= n {
				i = 0
			}
		}
		fmt.Println(0)
	}
}

C++: #include<iostream>

using namespace std;

int main(void){
	int n;
	int a[30];
	while(1){
		int o=32;
		scanf("%d",&n);
		if(n==0)break;
		for(int i=0;i<n;i++)scanf("%d",&a[i]);
		int c=0;
		while(o!=0){
			o-=(o-1)%5;
			printf("%d\n",o);
			o-=a[c];
			if(o<0)o=0;
			printf("%d\n",o);
			c++;
			if(c==n)c=0;
		}
	}
    return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;

int main()
{
	while (1) {
		int a;
		cin >> a;
		if (a == 0)break;
		vector<int>b(a);
		for (int c = 0; c < a; c++) {
			cin >> b[c];
		}
		uint16_t e = 31;
		for (uint16_t f = 0; f < 6; f++){
			cout <<e<<endl;
			cout << size(b);
			e -= 5;
		}
		cout << 1 << endl << 0 << endl;
	}
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef int INT;
typedef vector<INT> VI;
typedef vector<VI> VVI;
typedef pair <INT, INT> II;
typedef vector <II> VII;

template<class T> ostream& operator << ( ostream& os, vector<T> v ) {
    for ( typename vector<T>::iterator it_i = v.begin(); it_i != v.end(); ++it_i ) {
        os << *it_i << ", ";
    }
    return os;
}


void solve( int n, VI A ) {
    int remain = 32;
    bool flag = true;
    int k = 0;
    while( remain > 0 ) {
        if ( flag ) {
            int take = ( remain - 1 ) % 5;
            remain -= take;
            if ( remain < 0 ) remain = 0;
            cout << remain << endl;
        } else {
            remain -= A[k];
            if ( remain < 0 ) remain = 0;
            cout << remain << endl;
            k = ( k + 1 ) % n;
        }
        flag = !flag;
    }
}

int main() {
    int n;
    while ( cin >> n && n ) {
        VI A(n);
        for ( int i = 0; i < n; ++ i ) cin >> A[i];
        solve( n, A );
    }
    return 0;
}

C++: #include <iostream>

using namespace std;

void loop(int remain, int* jiro_rule, int rule_size, int cur) {
    remain -= (remain - 1) % 5;
    cout << remain << endl;
    if (remain == 0) return;
    if (remain < *(jiro_rule + cur)) {
        cout << 0 << endl;
        return;
    }
    remain -= *(jiro_rule + cur);
    cout << remain << endl;
    cur++;
    if (cur == rule_size) cur = 0;
    loop(remain, jiro_rule, rule_size, cur);
}

int main() {
    int i;
    while (cin >> i) {
        if (i == 0) break;
        int a[i];
        for (int p = 0; p < i; p++) {
            cin >> a[p];
        }
        loop(32, a, i, 0);
    }
    return 0;
}

C++: #include <iostream>
using namespace std;

int operate[25];
int main()
{
	int n;
	while(cin >> n){
		if(!n)
			break;
		int m = 31;
		for(int i=0;i<n;i++){
			cin >> operate[i];
		}
		int pos = 0;
		while(m>=0){
			m -= (m-1)%5;
			if(m<0)
				break;
			cout << m << endl;
			m -= operate[pos];
			if(m<0)
				break;
			cout << m << endl;
			pos++;
			if(pos==n)
				pos = 0;
		}
		cout << 0 << endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	while(true){
	int n=32,a,b[25]={0},c=0;
	cin>>a;
	if(a==0)break;
	for(int i=0;i<a;i++){
		cin>>b[i];
	}
	while(true){
		for(int i=0;i<a;i++){
			n=n-(n-1)%5;
			cout<<n<<endl;
			n=n-b[i];
				if(n<1){
				c=1;
				n=0;
				cout<<n<<endl;
				break;
			}
			cout<<n<<endl;
		}
		if(c==1)break;
	}
	}
}

C++: #include<stdio.h>
int main()
{
	int length,n,i,a[25];
	while(scanf("%d",&length),length)
	{
		for(i = 0; i < length; ++i)
			scanf("%d",&a[i]);
		bool isJiro=false;
		i = 0;
		n = 32;
		do
		{
			if(isJiro)
			{
				n -= a[i];
				i = (i+1)&length;
			}
			else
			{
				n -= (n-1)%5;
			}
			printf("%d\n",n>0?n:0);
			isJiro = !isJiro;
		}while(n>0);
	}
	return 0;
}

C++: #include<stdio.h>

int main(){

int n[5]={};
int N;
int r=0;
while(1){
scanf("%d",&N);if(N==0)break;

for(int i=0;i<N;i++)
scanf("%d",&n[i]);

int P=32;
int j=0;
while(1){
if(P<=0)break;
P-=(P-1)%5;printf("%d\n",P);
if(P==1)break;
P-=n[j];printf("%d\n",P);
j++;j=j%N;
}
P=0;printf("%d\n",P);
}
return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;

int main()
{
	while (1) {
		int a;
		cin >> a;
		if (a == 0)break;
		vector<int>b(a);
		for (int c = 0; c < a; c++) {
			cin >> b[c];
		}
		uint16_t e = 31;
		for (uint16_t f = 0; f < 6; f++){
			cout <<e<<endl;
			cout << (e - b[f % (b.size())]) << endl;
			e -= 5;
		}
		cout << 1 << endl << 0 << endl;
	}
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    int toru[n];
    int ohajiki=32;
    int cnt=0;
    for(int i=0;i<n;i++)
      cin>>toru[i];
    while(ohajiki!=0){
      if(cnt%2==0){
	ohajiki-=(ohajiki-1)%5;
	cnt++;
	if(ohajiki<0)
	  ohajiki=0;
	cout<<ohajiki<<endl;
      }else{
	ohajiki-=toru[(cnt/2)%n];
	//cout<<toru[(cnt/2)%n]<<endl;
	cnt++;
	if(ohajiki<0)
	  ohajiki=0;
	cout<<ohajiki<<endl;
      }
    }
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rrep(i,n) for(int i=(int)(n)-1; i>=0; i--)
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin(); it!=(c).end(); it++)
#define pb(a) push_back(a)
#define pr(a) cout << (a) << endl
#define PR(a,b) cout << (a) << " " << (b) << endl
#define F first
#define S second
typedef long long ll;
typedef pair<int,int> P;
const int MAX=1000000001;
const ll MAXL=1000000000000000001LL;
const ll mod=1000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int main() {
  int n;
  while(cin >> n && n) {
    int a[n];
    rep(i,n) cin >> a[i];
    int sum=32,k=0;
    bool t=false;  
    while(sum!=0) {
      if(!t) sum-=min(sum,(sum-1)%5);
      else sum-=min(sum,a[(k++)%n]);
      pr(sum);
      t=!t;
    }
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int i,n,hess,bell[100],riri=0,math=32;
  while(1){
    riri=0;
    cin >> n;
    if(n==0){
      break;
    }
    for(i=0;i<n;i++){
      cin >> bell[i];
    }
    hess=i;
    while(1){
      math-=(math-1)%5;

      if(math<0){
	math=0;
      }
      cout << math << endl;
      if(math<=0){
	math=32;
	break;
      }
      math-=bell[riri];
      riri++;

      if(math<0){
	math=0;
      }
      cout << math << endl;
      if(riri==hess){
	riri=0;
      }
      if(math<=0){
	math=32;
	break;
      }
    }
  }
  return (0);
}

C++: #include <bits/stdc++.h>

using namespace std;

#define MAX 26
 
int main()
{
    int n, a[MAX];
     
    while (cin >> n,n) {
        for (int i = 0; i < n; i++) cin >> a[i];
        int ohajiki = 32, j = 0, d = 0;
        while (1) {
            if (ohajiki == 1) break;
            if (j%2 == 0) {
                ohajiki -= (ohajiki-1)%5;
            } else {
                ohajiki -= a[d++];
                if (d == n) d = 0;
            }
            j++;
            cout << ohajiki << endl;
        }
        cout << '0' << endl;
    }
    return 0;
}