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()
{
  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;
    }
  }
}

C++: #include<iostream>
#include<algorithm>

using namespace std;

int main()
{
	for(int i;cin>>i,i;){
		int n=32,a[32];
		for(int j=0;j<i;j++)	cin>>a[j];
		for(int j=0;n>0;j=(j+1)%i){
			n-=(n-1)%5;
			cout<<n<<endl;
			n-=min(n,a[j]);
			cout<<n<<endl;
		}
	}
	return 0;
}

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

int main() {
    int n;
    while (cin >> n, n) {
        vector<int> a(n);
        for (int i=0; i<n; ++i) {
            cin >> a[i];
        }
        int x = 32;
        int k = 0;
        while (x) {
            x = max(0, x - (x - 1) % 5);
            cout << x << endl;
            if ( ! x) break;
            x = max(0, x - a[k]);
            cout << x << endl;
            k = (k + 1) % n;
        }
    }
    return 0;
}

C++: #include <cstdio>
#include <cstring>
main(){
int n,a[25];
while(scanf("%d",&n),n){
memset(a,0,sizeof(a));
for(int i = 0;i < n;i++)scanf("%d",a+i);
int i = 0,s = 32,t = 1;
while(s != 0){
(t)?s -= ((s - 1) % 5):s -= a[i++ % n];
if(s < 0)s = 0;
printf("%d\n",s);
t = !t;
}
}
}

C++: #include <iostream>

using namespace std;

int main() {

  int i;
  int a[30];

  int res;
  
  int index;


  while(1) {

    cin >> i;

    if(i==0) break;

    for(int j=0;j<i;j++) cin >> a[j];

    res=32;

    index=0;

    while(res>0) {

      res-=(res-1)%5;

      cout << res << endl;

      res-=a[(index%i)];

      if(res<0) res=0;

      index++;

      cout << res << endl;

    }

  }

  return 0;

}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	int m,n[100];
	while(true){
	cin>>m;
	if(m==0)
		break;
	for(int i=0;i<m;i++)
		cin>>n[i];
	int ans=31;
	int count=0;
	cout<<"31"<<endl;
	while(true){
		if(ans<n[count]){
			cout<<"0"<<endl;
			break;
		}
		ans-=n[count];
		cout<<ans<<endl;
		ans-=(ans-1)%5;
		cout<<ans<<endl;
		count++;
		count%=m;
	}
	}
	return 0;
}

C++: #include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<map>
#include<string>
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];           //次郎クン。実はHM
      if(r<0) r=0;
      printf("%d\n", r);

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

C++: #include<iostream>

#define MAX_LEN 32
using namespace std;

int main(){
	while(true){
		int i;
		int now = 0;
		int yama = 32;
		int jiro[MAX_LEN]={0,};
		scanf("%d", &i);
		if(i==0)break;
		for(int t = 0; t < i; ++t){
			scanf("%d", &jiro[t]);
		}
		while( yama > 0 ){
			yama -= ( yama - 1 ) % 5;
			printf("%d\n", yama);
			yama -= std::min( yama, jiro[now] );
			printf("%d\n", yama);
			++now;
			if(now>=i)now=0;
		}
	}
	return 0;
}

C++: 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <stdio.h>
 
int main(){
 
  int i,j,a[26];
  int n,h = 32;
 
 
  while(1) {
    h = 32;
  scanf("%d",&n);
  if(n == 0) break;
 
 
  for(i=0;i<n;i++) scanf("%d",&a[i]);
 
  i = 0;
  while(1) {
 
    h = h -(h-1)%5;
    printf("%d\n",h);
 
 
    h -= a[i%n];
    if(h>0) printf("%d\n",h);
    else {
      printf("0\n");
      break;
    }
 
    i++;
 
  }
   
  }
 
  return 0;
 
}

C++: #include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){

	int l;
	while(cin>>l&&l!=0){
		int a[26];
		for(int i = 0; i < l; i++){
			cin>>a[i];
		}
		int left=32;

		int tern=0;
		int idx=0;
		while(1){
			if(left==0)
				break;
			if(tern){
				left-=min(left,a[idx]);
				idx++;
				idx%=l;
			}
			else{
				left-=((left-1)%5);
			}
			cout<<left<<endl;
			tern^=1;
		}

	}
	return 0;
}

C++: #include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
//#include <utility>
#include <set>
#include <iostream>
//#include <memory>
#include <string>
#include <vector>
#include <algorithm>
//#include <functional>
#include <sstream>
//#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
//#include <cctype>
#include <cstring>
//#include <ctime>
#include <iterator>
#include <bitset>
//#include <numeric>
//#include <list>
//#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;

void mainmain(){
	int n;
	while(cin>>n,n){
		vint v(n);
		rep(i,n) cin>>v[i];
		int a=31;
		int c=0;
		cout<<a<<endl;
		while(a!=1){
			a-=v[c%n];
			cout<<a<<endl;
			a-=5-v[c%n];
			c++;
			cout<<a<<endl;
		}
		cout<<0<<endl;
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

C++: #include<iostream>
#include<string>
#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%(size(b))]) << endl;
			e -= 5;
		}
		cout << 1 << endl << 0 << endl;
	}
}

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

#define rep(i, n)for((i) = 0;(i) < (n);++(i))

int a[30];
int main(void){
	int i, j, n;
	for(;;){
		scanf("%d", &n);
		if(!n)break;
		rep(i, n)scanf("%d", &a[i]);
		j = 0;
		for(int x = 32;x;){
			x -= (x - 1) % 5;
			printf("%d\n", x);
			x = max(0, x - a[j]); j = (j + 1) % n;
			printf("%d\n", x);
		}
	}
}

C++: #include <iostream>
using namespace std;
int main(){
  int i=0 ,n ,total=32 ,length;
  while( cin >> length ){
    if( length == 0 ){
      break;
    }
    int jiro[length];
    
    for( int j=0 ; j<length ; j++ ){ // 次郎の取る数
      cin >> jiro[j];
    }
    
    while( 1 ){
      n = total; // 一郎のターン
      total -= (n - 1 ) % 5;
      if( total < 0 ){
	cout << "0" << endl;
	break;
      }
      cout << total << endl;
    
      total -= jiro[i]; // 次郎のターン
      i++;
      if( i == length ){
	i = 0;
      }
      if( total < 0 ){
	cout << "0" << endl;
	break;
      }
      cout << total << endl;
    }
    total = 32;
    i = 0;
  }
  return 0;
}