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<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;
			
			e -= 5;
		}
		cout << 1 << endl << 0 << endl;
	}
}

C++: #include<stdio.h>
int b[25];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++){
			scanf("%d",b+i);
		}
		int rem=32;
		int now=0;
		while(rem){
			rem-=(rem-1)%5;
			printf("%d\n",rem);
			if(rem==0)break;
			rem-=b[now++%a];
			if(rem<0)rem=0;
			printf("%d\n",rem);
		}
	}
}

C++: #include <iostream>
using namespace std;
int main(){
	int n;
	while(cin>>n,n){
		int N=32;
		int a[25];
		for(int i=0,an;i<n;++i){
			cin>>an;
			a[i]=an;
		}
		for(int i=0;N;i=(i+1)%n){
			N-=(N-1)%5;
			cout<<N<<"\n";
			N-=a[i];
			if(N<0) N=0;
			cout<<N<<"\n";
		}
	}
	return 0;
}

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

using namespace std;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		vector<int> Vec(n);
		for(int i = 0; i < n; ++i)
		{
			cin >> Vec[i];
		}
		int pos = 0;
		int ohajiki = 32;
		while(ohajiki > 0)
		{
			int temp = (ohajiki - 1) % 5;
			ohajiki -= temp;
			cout << ohajiki << endl;
			if(ohajiki <= Vec[pos])
			{
				ohajiki = 0;
			}
			else
			{
				ohajiki -= Vec[pos];
			}
			pos++;
			if(pos == n)
			{
				pos = 0;
			}
			cout << ohajiki << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

C++: 
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  while(1){
    cin>>n;
    if(n==0)break;
    vi a(n);
    rep(i,n)cin>>a[i];
    int sum=32;
    bool ans=false;
    rep(j,30){
      rep(i,n){
	sum-=(sum-1)%5;
	cout<<sum<<endl;
	sum-=min(sum,a[i%n]);
	cout<<sum<<endl;
	if(sum==0){
	  ans=true;
	  break;
	}
      }
      if(ans)break;
    }
  }
}

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

C++: #include <bits/stdc++.h>
using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int i;
  while(cin >> i && i){
    vary(int,a,i,0);
    rep(j,i){
      cin >> a[j];
    }
    int suf = 0,n = 32;
    while(n > 0){
      n -= (n-1)%5;
      cout << n << endl;
      n -= a[suf];
      n = (n < 0) ? 0 : n;
      cout << n << endl;
      ++suf;
      suf %= i;
    }
  }
  return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
main(){
  int N;
  while(~scanf("%d",&N)){
    int o = 32;
    int a[25]={};
    for(int i=0;i<N;i++){
      scanf("%d",&a[i]);
    }
    int i=0;
    while(o>0){
      o-=((o-1)%5);
      if(o<=0) o=0;
      printf("%d\n",o);
      if(o==0) break;
      o-=a[i];
      if(o<=0) o=0;
      printf("%d\n",o);
      i=(i+1)%N;
    }
  }
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    vector<int>in(n);
    rep(i,n)cin>>in[i];
    int ba=32;
    int i=0;;
    bool bn=true;
    while(ba){
      if(bn){
	ba-=(ba-1)%5;
	if(ba<0)ba=0;
	cout<<ba<<endl;
	bn^=1;
      }else{
	ba-=in[i];
	i++;
	if(i==n)i=0;
	if(ba<0)ba=0;
	cout<<ba<<endl;
	bn^=1;
      }
    }
  }
}

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

int main(){

	int n, v[26];
	int w[7] = {31, 26, 21, 16, 11, 6, 1};
	
	while(cin >> n){
		for(int i=0; i<n; i++){
			cin >> v[i];
		}
		
		cout << 31 << endl;
		for(int i=0; i<6; i++){
			cout << w[i] - v[i%n] << endl;
			cout << w[i+1] << endl;
		}
		cout << 0 << endl;
	}

	return 0;

}

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<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
using namespace std;
int inf = 1000000000;

int main(void) {

  int n;
  while(cin >> n){
    if( n == 0 ) break;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin >> a[i];

    int j = 0;
    int o = 32;
    int t = 0;
    while(o != 0){
      if( t%2 == 0 ) o -= (o-1)%5;
      else{
        o -= a[j];
        j++;
        j %= n;
      }
      if( o < 0 ) o = 0;
      cout << o << endl;
      t++;
    }

  }

  return 0;
}

// EOF