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>
#include<algorithm>
using namespace std;


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

C++: #include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

signed main(){
	int l;
	while(1){
		cin>>l;
		if(l==0) break;
		vi a(l);
		rep(i,0,l) cin>>a[i];
		int n=31;
		o(n);
		rep(i,0,10){
			int tmp=n-a[i%l];
			if(tmp<=0){
				o(0); break;
			}
			o(tmp);
			n-=5;
			o(n);
		}
	}
}

C++: #include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)

int main(){
    int n;
    while(scanf("%d",&n), n){
        int v[100];
        rep(i,n)scanf("%d",v+i);
        int r=32;
        rep(i,1000){
            if(i&1){
                r -= min(r, v[(i/2)%n]);
            } else {
                r -= min(r, (r-1)%5);
            }
            printf("%d\n",r);
            if(r==0) break;
        }
    }
}

C++: #include <stdio.h>

main(){
  int n=32;
  int m, data[25], i, j;
  while(1){
    scanf("%d", &m);
    if(m==0) break;

    n=32;
    for(i=0;i<m;i++){
      scanf("%d", &data[i]);
    }

    for(i=0;;i++){
      if(i==m) i=0;
      n-=(n-1)%5;
      if(n<0){
        printf("0\n");
        break;
      }
      printf("%d\n", n);
      n-=data[i];
      if(n<0){
        printf("0\n");
        break;
      }
      printf("%d\n", n);
    }
  }
  return 0;
}

C++: #include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n=31;
	int size;
	while(cin>>size){
		n=31;
		if(size==0)break;
		int dt[size];
		rep(i,size){
			cin>>dt[i];
		}
		int turn=1;
		int ite=0;
		while(n>=0){
			if(turn%2==1){
				n-=(n-1)%5;
				if(n<0) cout<<0<<endl;
				else cout<<n<<endl;
			}else{
				n-=dt[ite%size];
				if(n<0) cout<<0<<endl;
				else cout<<n<<endl;
				ite++;
			}
			turn++;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;

int main()
{
    int jiro[25];
    int l;
    int n;
    int index;
    while(cin >> l && l)
    {   
        n=32;
        index=-1;
        for(int i=0;i<l;++i) cin >> jiro[i];
        while(n)
        {   
            n -= (n-1)%5;
            cout << n << endl;
            n = max(n-jiro[++index], 0); 
            if(index >= l-1) index = -1; 
            cout << n << endl;
        }   
    }   
}

C++: #include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;

int main(){
    int a[10000];
    int cnt,i,turn,n;
    while(cin>>n&&n){
        turn=0,cnt=31;
        for(i=0;i<n;i++){
            cin>>a[i];
        }
        cout<<"31"<<endl;
        while(cnt>=a[turn%n]){
            cnt-=a[turn%n];
            turn++;
            if(cnt==0) break;
            cout<<cnt<<endl;
            cnt-=(cnt+4)%5;
            cout<<cnt<<endl;
        }
        cout<<"0"<<endl;
    }
    return 0;
}

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

int main(void){
	while(1){
		int n;
		vector<int> num;
		cin >> n;
		if(n == 0) break;

		for(int i=0; i<n; i++){
			int t;
			cin >> t;
			num.push_back(t);
		}

		int a = 32;
		int i=0;
		while(1){
			a -= (a-1)	% 5;
			if(a <= 0) {
				cout << 0 << endl;
				break;
			}
			cout << a << endl;
			a -= num[i % num.size()];
			i++;
			if(a <= 0) {
				cout << 0 << endl;
				break;
			}
			cout << a << endl;
		}

	}


	return 0;
}

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

C++: #include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
#include <map>
using namespace std;
int main(){
	
	int n;
	
	while(cin>>n,n!=0){
		int s=32;
		int k=0;
		int f=0;
		vector<int> a(n);
		for(int i=0;i<n;i++)
			cin>>a[i];
		
		while(s!=0){
			if(f==0){
				s-=(s-1)%5;
				f++;
			}
			else{
				s=s-a[k++];
				f=0;
				if(k==n-1)
					k=0;
			}
			if(s<0){
				s=0;
			}
				cout<<s<<endl;
		}
	}
	
}

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

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	for(int n;cin>>n,n;){
		vi a(n);
		rep(i,n)
			cin>>a[i];
		int res=32;
		for(int i=0;res;i++){
			int n1=(res-1)%5;
			res-=n1;
			cout<<res<<endl;
			int n2=min(res,a[i%a.size()]);
			res-=n2;
			cout<<res<<endl;
		}
	}
	
	return 0;
}

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<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    int a[n],s=32,p=0;
    for(int i=0;i<n;i++)cin>>a[i];
    while(s){
      s-=(s-1)%5;
      cout<<s<<endl;
      s-=a[p++%n];
      if(s<0)s=0;
      cout<<s<<endl;
    }
  }
}

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

int main()
{
  int len;

  while (scanf("%d", &len), len){
    int a[25];
    for (int i = 0; i < len; i++){
      scanf("%d", &a[i]);
    }
    int n = 32;
    for (int i = 0, j = 0;; i++){
      if (i % 2 == 0){
        n -= (n - 1) % 5;
      }
      else {
        n -= a[j % len];
        j++;
      }
      if (n <= 0){
        n = 0;
        printf("%d\n", n);
        break;
      }
      printf("%d\n", n);
    }
  }

  return (0);
}