semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
	int n,t,i,j,a[100]={0},q=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
   scanf("%d",&t);
   for(j=0;j<t;j++)
   scanf("%d",&a[j]);
   for(j=0;j<t;j++)
   if((a[j]+j*3<=60)&&((a[j+1]+(j+1)*3>60)||(a[j+1]==0)))
	   {
   if(a[j]+3*j+6<=60) printf("%d\n",60-j*3-3);
   else printf("%d\n",a[j]);
   if(j==t-1) q=1;
   break;
	   }
	   if((q==0)&&(j==t)) printf("%d\n",60-t*3);
	else if(t==0) printf("60\n");
	for(j=0;j<t;j++)
		a[j]=0;
	}

  return 0;
}
int main()
{
	int n, time, i, j, num[100], shu;
	cin >> n;
	for( i = 0; i < n; i ++ )
	{
		shu = 0;
		memset(num, 0, sizeof(num));
		cin >> time;
		if( time == 0 )
			cout << 60 << endl;
		else
		{
			for( j = 0; j < time; j ++ )
			{
				cin >> num[j];
			}
		    for( j = 0; j < time; j ++ )
			{
				shu = num[j] + 3 * (j + 1);
				if( shu > 60 )
				{
					if( num[j] + 3 * j <= 60 )
					{
						shu = num[j];
						break;
					}
					else
						shu = 60 - ( num[j - 1] + 3 * j ) + num[j - 1];
					    break;
				}
			}
			if( j == time )
				shu = 60 - 3 * time;
			cout << shu << endl;
		}
	}
	return 0;
}
//============================================================================
// Name        : tiaosheng.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================


int main() {
	 int num;
	       cin>>num;
	       for(int i=1;i<=num;i++)
	       {  int t,times=0;
	          int a[21];
	          cin>>t;
	          if(t==0)cout<<60<<endl;
	          else
	         {
	        	  for(int j=0;j<t;j++)
	        	  {
	        		  cin>>a[j];
	        	  }
	        	  if((a[t-1]+t*3)<60){times=60-t*3;}
	        	   else
	        	       {
	        	            for(int j=0;j<t;j++)
	        	             	 {

	        	         		  	  if((a[j]+(j+1)*3)>=60&&(a[j]+(j+1)*3)<=63)
	        	         		  	   {
	        	         		            times=a[j];
	        	         		              break;
	        	         		  	   }
	        	         		  	  if((a[j]+(j+1)*3)>63)
	        	         		  	   {
	        	         		  		  times=a[j-1]+60-a[j-1]-j*3;

	        	         		  		  break;
	        	         		  	   }

	        	             	   }
	        	               }

	        	           cout<<times<<endl;

	        	         }

	         }
	return 0;
}
/**
*@file		1000012767_6.cpp
*@author	??
*@date		2010.11.24
*@description
*			???????????
*/
int main()
{
	int n, m, i, jump, sum;
		//n ?????m ?????i ?????jump ?????????sum 60s ????
	cin >> n;
	while (n--)
	{
		cin >> m;
		if (m == 0)			//?????????????
		{
			sum = 60;
			cout << sum << endl;
			continue;
		}
		for (i = 1; i <= m; i++)	//????????????????
		{
			cin >> jump;
			if (jump + i * 3 > 60 && jump + (i - 1) * 3 <= 60)
			{						//????????? 60s ??????? 60s
				sum = jump;			//????????????????
				break;				//????????????
			}
			else if (jump + (i - 1) * 3 > 60)
			{						//??????????? 60s
				sum = 60 - (i - 1) * 3;	
				break;				//????????????????
			}						//????????????
			if (i == m)				//????????????? 60s
				sum = 60 - i * 3;	//?????????????
		}
		cout << sum << endl;
									//????????????????????
		for (i = i + 1; i <= m; i++)
			cin >> jump;	
	}
	return 0;
}
int main(){
	int n,suspend,number,times;
	//n???????suspend??????number??????times??????
	cin>>n;
	for(;n>0;n--){
		cin>>number;
		times=60;
		for(;number>0;number--){
			cin>>suspend;
			if(suspend<times-2)times-=3;
			else if(suspend>=times);
			else times=suspend;
		}
		cout<<times<<endl;
	}
	return 0;
}
int main(){  
  int i,j,n,w,sum,flag,k,x;  
  scanf("%d",&n);  
  for(i=0;i<n;i++)    {     
   scanf("%d",&w);
flag=0;       
 for(j=0;j<w;j++)        {     
       scanf("%d",&sum);   
         if(flag!=-1&&(sum+3*(j+1))>59){
flag=1;
break;
}     
  }     
   for(k=j+1;k<w;k++)       
     scanf("%d",&x);       
 if(flag&&(sum<=60)&&((sum+3*j)<=60))          
  printf("%d\n",sum);
        else       
     printf("%d\n",60-j*3);
  }    
return 0;
}
int main()
{
    int n,i,j,k,m,b[100];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
	    scanf("%d",&m);
		if(m==0)
		{
		    printf("60\n");
		}
		if(m!=0)
		{
			for(j=0;j<m;j++)
			{
			    scanf("%d",&b[j]);
			}
			for(k=m;k>0;k--)
			{
			    if(b[k-1]+3*k<=60)
				{
				    printf("%d\n",60-3*k);
					break;
				}
				else if(b[k-1]+3*k==61 || b[k-1]+3*k==62 || b[k-1]+3*k==63)
				{
				    printf("%d\n",b[k-1]);
					break;
				}
				else if(b[k-1]+3*k>63)
				{
				    continue;
				}
			}
		}
	}
	return 0;
}
int i,n,m,j,k;
int p,q,r;
int t[99];

int main()
{
	cin>>n;
	for (i=1;i<=n;i++)
	{
		cin>>m;
		r=0;
		for (j=1;j<=90;j++) t[j]=1;
		for (j=1;j<=m;j++)
		{
			cin>>p;
			q=0;k=1;
			do
			{
				q=q+t[k];
				k++;
			}
			while (q!=p);
			t[k]=0;k++;
			t[k]=0;k++;
			t[k]=0;
		}
		for (j=1;j<=60;j++) r=r+t[j];
		cout<<r<<endl;
	}
	return 0;
}
/*
 * tsyx.cpp
 *
 *  Created on: 2010-12-29
 *      Author: dell
 */
int main(){
	int i,n,s=0,j;
	cin>>n;
	int cishu[n],time[n],shijian[n];
	for(i=0;i<n;i++){
		time[i]=0;
		shijian[i]=0;
		cin>>cishu[i];
		if(cishu[i]==0) {cout<<60<<endl; continue;}
		int cxia[cishu[i]];
		for(j=0;j<cishu[i];j++)
			cin>>cxia[j];
		if((cishu[i]*3+cxia[j-1])<=60){
			time[i]=60-cishu[i]*3;
		}
		else {
			s=0;
			for(time[i]=0;time[i]<60;){
				if(time[i]==cxia[s]) {shijian[i]=shijian[i]+3;s++;}
				else{
					shijian[i]++;
					time[i]++;
				}
				if(shijian[i]>=60) break;
			}
		}
		cout<<time[i]<<endl;
	}
	return 0;
}
int main(int argc, char *argv[])
{
    int n,m,a[10],sum,you,i,j;
    scanf ("%d",&n);
    for (i=0;i<n;i++)
    {   sum=0;you=0;
        scanf ("%d",&m);
        if (m==0)
        printf ("60\n");
        else 
        {
        for (j=0;j<m;j++)
        {
            scanf ("%d",&a[j]);
        }
        for (j=0;j<m;j++)
        {
            sum=a[j]+3*j;
            if (sum>=60)
            {
               you=60-3*j;break;
            }   
            else if (sum<57&&j==m-1)
                {you=60-3*(j+1);break;}
            else if (sum>57)
               { you =60-3*j-(60-sum);break;}
        }
        printf ("%d\n",you);
        }
        }
        scanf ("%d",&i);
        return 0;
        }
int main()
{   
	int n,m;
	int i,j;
	int wrong[60];
	int contine[60];
	int sum;
	cin>>n;
	
	for(i=0;i<n;i++)
	{
		cin>>m;
		j=1;
		sum=0;

		if(m==0)
			sum=60;                             //m==0????

		while(j<=m)
		{
			cin>>wrong[j];                      //????????
			contine[j]=wrong[j]+3*j-3;
			j++;
		}

		for(j=1;j<=m;j++)
		{
			if((contine[j]>=57)&&(contine[j]<60))
				{
					sum=wrong[j];                         
					break;
			    }
			else if(contine[j]>=60)
				{
					sum=60-3*(j-1);
					break;
			    }
		}
		if(j==m+1)
			sum=60-3*m;
		cout<<sum<<endl;
	}
	return 0;
}
int main(int argc, char* argv[])
{
	int n;
	scanf("%d\n",&n);
	int k,p[20];
	int i,l;
	int j;
	int sum;
	for (i=0;i<n;i++){
		scanf("%d",&k);
	if (k==0) printf("60\n");
	else {
		
	for (j=1;j<=k;j++){
		scanf("%d",&p[j]);
	}
	
	for (j=1;j<=k;j++){
		sum=3*(k-1)+p[k];}
	if (sum<=60){
	for (j=1;j<=k;j++){
		if ((60-sum)>=3){
			l=p[k]+(60-(p[k]+(3*k)));}
		if((60-sum)<3){
			l=p[k];}
	}
	printf("%d\n",l);}
	if(sum>60){
	for (j=1;j<=k;j++){
	 if((60-(p[j-1]+(j-2)*3))*(60-(p[j]+(j-1)*3))<0){
		if 	((60-(p[j-1]+(j-2)*3))>=3)
		{l=p[j-1]+(60-(p[j-1]+(j-1)*3));}
		if ((60-(p[j-1]+(j-2)*3))<3){
			l=p[j-1] ;}   
		} 
	}
	printf("%d\n",l);}
	}
	}
	return 0;
}
int main()
{int n,m,a[1000][15],b[1000],c[1000],t[1000][15],i,k;//????
cin>>n;//????
for(i=0;i<n;i++)//????????????????????
	{cin>>m;
     b[i]=m;
for(k=0;k<m;k++)
	{cin>>a[i][k];
if(a[i][k]<=62-3*(k+1))//???????????????????????
	{c[i]=a[i][k];//?????????????????
     b[i]=k+1;}}}//??????????
for(i=0;i<n;i++)
  {if(c[i]>=62-3*b[i])//???????????????????????
		t[i][k]=c[i];//???????????????????????????????????????????
	else t[i][k]=60-3*b[i];//???????????????
    cout<<t[i][k]<<endl;}//????
return 0;
}
int main()
{
	int n;
	scanf("%d",&n);
	int i,j;
	int a[100],b[100][100];
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		if(a[i]==0){
		}else{
			for(j=0;j<a[i];j++){
				scanf("%d",&b[i][j]);
			}
		}
	}
	for(i=0;i<n;i++){
		if(a[i]==0){
			printf("60\n");
		}else{
			for(j=0;j<a[i];j++){
				if((b[i][j]+3*j)>=60){
					printf("%d\n",60-3*j);
					break;
				}else if(((b[i][j]+3*j)>=57)&&((b[i][j]+3*j)<60)){
					printf("%d\n",b[i][j]);
					break;
				}else{
					if(j==a[i]-1){
						printf("%d\n",57-3*j);
					}
				}
			}
		}
	}
	return 0;
}
int main()
{
    int s[200]={0},f[200]={0}, n, m[200]={0}, i, j,count=0;
    cin >> n;
    for (i=1;i<=n;i++)
    {
         for (j=1;j<=199;j++) s[j]=1;
         memset(f,0,sizeof(f));
         count=0;
         cin >> m[i];
         for (j=1;j<=m[i];j++)
         {
             cin >> f[j];
             s[f[j]-2+3*j]=0;
             s[f[j]-1+3*j]=0;
             s[f[j]+3*j]=0;
         }
         for (j=1;j<=60;j++) count=count+s[j];
         cout << count << endl;
    }
    return 0;
}
//??:??????
int main()
{
	int i,j,k,num,n,time1,time2,a[100];//????
	cin>>n;//????????
	for(i=0;i<n;i++)
	{
		cin>>num;//??????
		if(num==0)//???????????
			cout<<"60"<<endl;
		else
		{
			for(j=1;j<=num;j++)
				cin>>a[j];//????
			if((a[num]+3*num)<=60)
			{
				cout<<60-3*num<<endl;
				continue;
			}
			for(k=1;k<=num;k++)
			{
				time1=a[k]+3*(k-1);//?????????
				time2=a[k]+3*k;
			
				if(time1>=60)
				{
					cout<<60-3*(k-1)<<endl;//?????????
					break;
				}
				if(time2>=60)
				{
					cout<<a[k]<<endl;
					break;
				}
			}
		}
	}
	return 0;
}
int main()
{
	int a,i,j,d,b[100][100];
	scanf("%d",&a);
	for(i=0;i<a;i++){
		scanf("%d",&b[i][0]);
		for(j=1;j<=b[i][0];j++){
			scanf("%d",&b[i][j]);
		}
	}
	for(i=0;i<a;i++){
		if(b[i][0]==0){
			printf("60\n");
		}
		else{
		d=0;
        for(j=1;j<=b[i][0];j++){
			d=d+3;
			if(b[i][j]+d>=60){
				break;
			}
		}
		if(j-1==b[i][0]){
			printf("%d\n",60-d);
		}
		else if(b[i][j]+d-60<=3){
			printf("%d\n",b[i][j]);
		}
		else if(b[i][j]+d-60>3){
			printf("%d\n",60-d+3);
		}
		}
	}



	return 0;
}
/**
 *file:????11-24??
 *author:???
 *date?201011-26
 *discription?????
 */
int main ()
{
	//?????????????????????????????i.j.k;
	int n , m , i , j , k ;
	cin >> n ;
	for ( i = 1 ; i <= n ; i ++ )
	{
		cin >> m ;
		//???????0?????60?
		if ( m == 0 )
		{
			cout << "60" << endl ;
		}
		else 
		{
			//???????i????????num[i],?????k?0?
			int num[60] = { 0 } ;
			k = 0 ;
			for ( j = 1 ; j <= m ; j ++ )
			{
				cin >> num[j] ;
				//?????????????????????k??
				if ( num[j] + j * 3 <= 63 ) k = j ;
			}
			//???k?????????????????????????????????????????3*k????????????
			if ( num[k] + k * 3 <= 60 )
				cout << 60 - k * 3 << endl ;
			//???k???????????3??????k???????????
			else cout << num[k] << endl ;
		}
	}
	return 0 ;
}
int main(){
int n,a,num,c;
    scanf("%d",&n);
    for(c=0;c<n;c++)
    {
    int m;
    scanf("%d",&m);
	if(m==0){ 
		num=60;
		printf("%d\n",num);
	}
    else{
    int*shuzu=(int*)malloc(sizeof(int)*m);
    for(a=0;a<m;a++)
    {
       scanf("%d",&shuzu[a]);
     }
    if(shuzu[m-1]>60-3*(m-1)-1)
	{       
        int b=m-2;
		int i;
        for(i=b;i>=0;i--)
		{
            if(shuzu[i]>60-3*i-1) continue;
            if((shuzu[i]<=60-3*i-1)&&(shuzu[i]>60-3*i-3)){ 
				num=shuzu[i];
				break;
			}
			if(shuzu[i]<=60-3*i-3){
				num=60-3*i-3;
				break;
			}
		}
	}
    
    if((shuzu[m-1]<=60-3*(m-1)-1)&&(shuzu[m-1]>60-3*(m-1)-3)) num=shuzu[m-1];
    if(shuzu[m-1]<=60-3*(m-1)-3) num=60-3*(m-1)-3;
	
	printf("%d\n",num);
    free(shuzu);
	}
	}
    
    return 0;
}
int main()
{
	int n;
	int a[100];
	int sum[100];
	int i,j,k;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&j);
		for(k=1;k<=j;k++)
		{
			scanf("%d",&a[k-1]);
		}

    	if(j==0)
		{
			sum[i]=60;
		}
		else if(j==1)
		{
			if(a[0]<=57)
			{
				sum[i]=57;
			}
			else
			{
				sum[i]=a[0];
			}
		}
				
		else
		{   
			if(a[j-2]+3*(k-1)>=60)
			{
			j=j-1;
			}

		
			if(a[j-1]+3*j<=60)
			{
				sum[i]=60-3*j;
			}
			else if(a[j-1]+3*(j-1)<=60&&a[j-1]+3*j>60)
			{
				sum[i]=a[j-1];
			}

		    else if(a[j-2]+3*(j-1)<=60&&a[j-1]+3*(j-1)>60)
			{
		     	sum[i]=60-3*(j-1);
			}
	    	else 
			{
				sum[i]=a[j-2];
			}
		}
	}


		
	for(i=0;i<n;i++)
	{
	    printf("%d\n",sum[i]);
	}
	return 0;
}
int main()
{
	int n,m[100],i,j,a[100][10],sum;
	scanf("%d",&n);
	for(i=0;i<100;i++)for(j=0;j<100;j++)a[i][j]=100;
	for(i=0;i<n;i++)
	{
		scanf("%d",&m[i]);
		for(j=0;j<m[i];j++)scanf("%d",&a[i][j]);
	}
	for(i=0;i<n;i++)
	{
		j=0;
		while((a[i][j]+3*(j+1))<60)j++;
		sum=60-3*j;
		if(a[i][j]+3*(j+1)<63)sum=sum-(63-a[i][j]-3*(j+1));
		printf("%d\n",sum);
	}
	return 0;
}
/*
 * 111230_Skipping.cpp
 *
 *  Created on: 2011-12-30
 *      Author: Alfalfa
 */
int main(){
	int n;
	cin>>n;
	while(n){
		n--;
		int miss,all=60,time=0,allmiss=0,flag=0,all1;
		cin>>miss;
		while(miss){
			miss--; allmiss++;
			int num;
			cin>>num;
			time=num+allmiss*3;
			all=num;
			if(time>=63&&flag==0){
				all1=60-(allmiss-1)*3;
				flag=1;
			}
			else if(time>=60&&flag==0){
				all1=all;
				flag=1;
			}
		}
		if(flag==1) cout<<all1<<endl;
		else cout<<60-allmiss*3<<endl;
	}
}
int main()                                       //?????
{
	int n,m,i,j,k=0,a;
	int num[20]={0};
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>m;
		if(m==0)
		{
			cout<<60<<endl;}
		else
		{for(j=1;j<=m;j++)
		{
			cin>>a;
			if(k==1)
				continue;
			else
			{   num[j]=a;
			  if(num[j]+3*(j-1)==59)
				 { cout<<num[j];
			  k=1;}
			  else if(num[j]+3*(j-1)>59)
				  {cout<<60-3*(j-1)<<endl;
			  k=1;}
			  else if(num[j]+3*(j-1)<59&&num[j]+3*j>59)
			{cout<<num[j]-3*(j-1)<<endl;
			  k=1;}
			  else if(j==m)
			cout<<60-3*j<<endl;}}}
	k=0;}
		return 0;
}
int main()
    {int n;
    cin>>n;//????
    for(;n>=1;n--)
        {int m;
    	cin>>m;//??????????
    	int broke[m+1];//????????????
    	int i,total[61]={0},count=0;
    	for(i=1;i<=60;i++)
    		total[i]=1;//total[61]??1-60?????1???0??
    	if(m==0)cout<<"60"<<endl;//??0?
    	else//????1?
    	   {for(i=1;i<=m;i++)
    		    {cin>>broke[i];//???????i??????
    		    broke[i]=broke[i]+(i-1)*3;//???i??????broke[i]??
    		    }
    	    for(i=1;i<=m;i++)//?????60??????total????0
    	        {if(broke[i]+1<=60)total[broke[i]+1]=0;
    	        else break;
    	        if(broke[i]+2<=60)total[broke[i]+2]=0;
    	         else break;
    	        if(broke[i]+3<=60)total[broke[i]+3]=0;
    	          else break;
    	        }
    	    for(i=1;i<=60;i++)//??????
    	    	count=count+total[i];
    	    cout<<count<<endl;
    	    count=0;//?????
        	for(i=1;i<=60;i++)
        		total[i]=1;
    	   }
        }
    return 0;
    }
int main(){
int i,huai,n,j,sz[100],k,r;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&huai);
if(huai==0&&i==n-1){
	printf("60");
	break;
}
if(huai==0&&i!=n-1){
	printf("60\n");
	continue;
}
for(j=0;j<huai;j++){
scanf("%d",&sz[j]);
}
for(j=0;j<huai;j++){
k=sz[j]+3*(j+1);
if(k>=60) break;
}
if(j==huai) r=60-3*huai;
if(k>=60&&k<=63) r=sz[j];
if(k>63) r=60-3*j;
if(j==n-1){
	printf("%d",r);}else{
	printf("%d\n",r);
	}
}
	return 0;
}
int main(int argc, char* argv[])
{
    int n,k,*p,i,j ;
	scanf("%d",&n);
    for(i=0;i<n;i++)
	{
		scanf("%d",&k);
		p=(int*)malloc(sizeof(int)*k);
		if(k==0)printf("60\n");
		else
		{
			for(j=0;j<k;j++)
			{
				scanf("%d",&*(p+j));
			}
			if(p[k-1]+3*(k)<=60)printf("%d\n",60-k*3);
			else{
				for(j=0;j<k;j++)
				{
					if(p[j]+3*j>60)
					{
						printf("%d\n",60-j*3);
						break;
					}
					if(p[j]+3*(j+1)>60)
					{
						printf("%d\n",p[j]);
						break;
					}
				}
		    }
		 }
	}
	return 0;
}
//============================================================================
// Name        : grids.cpp
// Author      : Liang ShiYu
// Version     : 1.0
// Copyright   : Copyright Reserved
// Description : HomeWork
// Date        : 2010-12-17
//============================================================================


int main() {
	int n,data[100][20],answer[100];
	for(int i=0;i<100;i++) answer[i]=60;
	cin>>n;
	for(int i=0;i<n;i++){
		int m;
		cin>>m;
		for(int j=0;j<m;j++) {
			cin>>data[i][j];
			if(data[i][j]<=answer[i]-3) answer[i]-=3;
			else if(data[i][j]>=answer[i]);
			else answer[i]=data[i][j];
		}
	}
	for(int i=0;i<n;i++) cout<<answer[i]<<endl;
	return 0;
}
int main()
{
	int i = 0, j = 0, total = 0 , n = 0, m = 0,temp = 0;
	scanf("%d",&n);
	
	for(i = 0; i < n ; i++)
	{
		scanf("%d",&m);
		total = 60;
		for( j = 0;j < m ; j++)
		{
			scanf("%d",&temp);
			if(temp > total)
			break;
			if(temp + 3 >= total)
			{
				total = temp;
				break;
			}
			else 
			{
				total -= 3;
			}
		}
		printf("%d\n",total);
		while((getchar())!='\n')
		continue;
	}

	return 0;
}
int main()
{
    int i,n,m,flag,a;
	scanf("%d",&n);
	for (i=0; i<n; i++){
		flag=1;
		scanf("%d",&m);
		for (int j=0;j<m; j++){
			scanf("%d",&a);
			if (((a+j*3)>=60)&&(flag)){
				flag=0;
				printf("%d\n",60-3*j);
			}else if (((a+j*3+3>=60))&&(flag)){
				flag=0;
				printf("%d\n",a);
			}
		}
		if (flag) {
			printf("%d\n",60-3*m);
		}
	}
	return 0;
}
int main()
{
	int n,m,a[100],i,j,c=0,d=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		
		scanf("%d",&m);
		for(j=0;j<m;j++)
		{
			scanf("%d",&a[j]);
		}
        c=0;
		d=0;
		
		for(j=0;j<m;j++)
		{
		    if((60-a[j]-3*j)<3 && (60-a[j]-3*j)>0)
			{
			   printf("%d\n",a[j]);
			   c=1;
			   break;
			}
		}
		if(c==0)
		{
           for(j=0;j<m;j++)
		   {

	
		      if(a[j]>=(60-3*j))
			  {
			    printf("%d\n",60-3*j);
                d=1;
				break;
			  }
		   }
		
		
          if(d==0)
		  {
		    printf("%d\n",60-3*m);
		   }
		}
		
	
	}
	return 0;
}
int main(){
    int n;
    scanf("%d", &n);
    int m, timeCount, numCount;
    int num[60];
    while(n--){
        scanf("%d", &m);
        for(int i = 0; i < m; ++i){
            scanf("%d",& num[i]);
        }
        timeCount = numCount = 0;
        for(int i = 0; i < m; ++i){
            for(int j = numCount; j < num[i]; ++j){
                if(timeCount >= 60) break;
                timeCount ++;
                numCount ++;
            }
            if(timeCount >= 60) break;
            timeCount += 3; 
            //printf("i, timeCount, numCount: %d, %d, %d\n", i, timeCount, numCount);
        }
        for(; timeCount < 60; ++timeCount){
            numCount ++;
        }
        printf("%d\n", numCount);
    }
   
}
int main()
{
	int n,i,j,time[100],fail[100][20],m[100],sum=0;
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d",&m[i]);
		if (m[i]!=0){

			for(j=0;j<m[i];j++){
				scanf("%d",&fail[i][j]);
			}
		}
		else continue;
		
		
	}
	for(i=0;i<n;i++){
		for(j=0;j<100;j++){
			time[j]=1;
		}
		if(m[i]!=0){

			for (j=0;j<m[i];j++){
				time[fail[i][j]+j*3]=time[fail[i][j]+1+j*3]=time[fail[i][j]+2+j*3]=0;
			}
		
	
			sum=0;
			for(j=0;j<60;j++){
			
				sum+=time[j];
				
			}
			printf("%d\n",sum);
		}
		else{
			printf("60\n");
		}

	}
	return 0;
}
int main(){
	int n,i,j,h,m,t=0,l,s=0;
	int a[10000];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		s=60;
		t=0;
		scanf("%d",&m);
		for(j=0;j<m;j++){
			scanf("%d",&a[j]);
		    t++;
			if(a[j]+3*t<=58){
				s=s-3;
			} if(a[j]+3*t>62){
				s+=0;
			}else if(a[j]+3*t>60&&a[j]+3*t<63){
				s=a[j];
				break;
			}
		}printf("%d\n",s);
		
	}
	return 0;
}
int main()
{
    int a=0,b=0,c=0,d=0,e=0,f=0,i=0;
    cin>>a;//a????
    for(e=1;e<=a;e++)
    {
        cin>>b;//?????b
        if(b==0) cout<<"60"<<endl;
		else
        {
            for(c=1;c<=b;c++)
            {
                cin>>d;//???d?
                if((d+3*c)<=60)//???1??????
                {
                    i=d-((d+3*c)-60);//????1????????????
                    f=60-3*c;
                }
                else if(((d+3*(c-1))<=60)&&((d+3*c)>60))//???????????????1??????
                {
                    i=d;//????1????????????
                    f=d;
                }
                else//??1??????
                {
                    f=i;//????????
                }
            }
            cout<<f<<endl;
        }
    }
	return 0;
}
//????


int main()
{
	int n,m,sum,i,j;          //????
	int a[20];                //????????????????????
	cin>>n;                   //???????
	for (i=1;i<=n;i++)        //????????????????????
	{
		sum=60;               //???sum????60
		cin>>m;               //??????m
		for (j=1;j<=m;j++)    //????????m?????
		{
			cin>>a[j];                    //???j????????
			if (a[j]+3*(j-1)<57)          //??????????57???sum=60-3*????
				sum=60-3*j;
			else if (a[j]+3*(j-1)>=60)    //?????60?????????sum??
				continue;
			else                          //????57?58?59???sum??a[j]
				sum=a[j];
		}
		cout<<sum<<endl;                  //????
	}
	return 0;
}
int main()
{
    int a,n,i,sum,temp;
    int k[100];
    cin>>n;
    while(n>0)                      //????
    {    sum=0;
        cin>>a;
        if(a==0) cout<<60<<endl;
        for(i=0;i<a;i++)             //??
        cin>>k[i];
         if(k[a-1]+a*3<60)
         cout<<60-a*3<<endl;
         else {
             for(i=0;i<a;i++)                //????
             { if((k[i]+(i+1)*3)<60&&(k[i+1]+(i+2)*3>60))
             {    temp=60-(i+1)*3;
                 if(k[i+1]==temp-1)
                 cout<<temp-1<<endl;
                 else cout<<temp<<endl;
             }
             }
         }


     n--;
    }
    return 0;
}
int main()
{
	int n,b[10],a[10][10],i,j,t[10];   //a[10][10]???????????????????????total???????????
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>b[i];
		for(j=1;j<=b[i];j++) 
			cin>>a[i][j];
	}
	/*for(i=1;i<=n;i++)
		cout<<b[i];
		for(i=1;i<=n;i++)	
			for(j=1;j<=b[i];j++)
				cout<<a[i][j];
	return 0;
}
*/
	for(i=1;i<=n;i++)
	{	
		for(j=1;j<=b[i];j++)
		{
			if((a[i][j-1]+3*(j-1)<60)&&(a[i][j]+3*j>60))
				t[i]=3*j-3;
			if((a[i][j]+2*j<=60)&&(a[i][j]+3*b[i]>60))
				t[i]=60-a[i][j];
		}
		if(a[i][b[i]]+3*b[i]<60)
			t[i]=3*b[i];
		if((a[i][b[i]]+2*b[i]<=60)&&(a[i][b[i]]+3*b[i]>60))
			t[i]=60-a[i][b[i]];
	}
	for(i=1;i<=n;i++)
	{
		cout<<60-t[i]<<endl;
	}
	return 0;
}
int main()
{
	int n,m,c,t,u[60],i;
	cin>>n;
	while (n>0)
		{
			cin>>m;
			c=0;t=-3;u[0]=0;
			for (i=1;i<=m;i++) cin>>u[i];

			for (i=1;i<=m;i++)
					if (u[i]-u[i-1]+t+3<=60)
						{
							t=u[i]-u[i-1]+t+3;
							c=u[i];
					  }
					else break;
					t=t+3;
			if (t<60) c=c+60-t;
			cout<<c<<endl;
			n--;
	  }
return 0;
}
int main()
{
	int n,k;
	scanf("%d",&n);
	for(k=0;k<n;k++)
	{
		int j,count=0,time=0,duan;
		int sz[30];
		scanf("%d",&duan);
		for(j=0;j<duan;j++)
		{
			scanf("%d",&sz[j]);
		}
		if(duan==0)
		{
			printf("60\n");
		}
		else if(duan==1)
		{
			if(sz[0]>57)
			{
				printf("%d\n",sz[0]);
			}
			else
			{
				printf("57\n");
			}
		}
		else
		{
			count=sz[duan-3];
			time=count+3*(duan-3);
			time=time+3;
			if(sz[duan-2]+(duan-2)*3<60)
			{
				count=sz[duan-2];
				time=count+(duan-1)*3;
			    if(sz[duan-1]+(duan-1)*3<60)
				{
				    count=sz[duan-1];
				    time=count+(duan)*3;
				    while(time<60)
					{
				        count++;
				        time++;
					}
				}
				else
				{
					while(time<60)
					{
						count++;
						time++;
					}
				}
			}
			else
			{
			    while(time<60)
				{
				    count++;
			    	time++;
				}
			}
			printf("%d\n",count);
		}
	}
	return 0;
}
void main()
{
 int n, i, j, m, a[100],  num[100];
 scanf("%d",&n);
 for(i=0;i<n;i++){
     scanf("%d", &m);
     for(j=1;j<=m;j++){
       scanf("%d", &a[j]);
	 }
     if(3*m+a[m]<=60)
	 {
     num[i]=60-3*m;
	 }
	 else
	 {
         for(j=m;j>=0;j--)
		 {
		    if(3*j+a[j]<=63&&3*j+a[j]>60)
			{             
		    	num[i]=a[j];
		    	break;
			} 
		 
            else if(3*j+a[j]<=60)
			{
		    	num[i]=60-3*j;
                break;
			}
		 }
	 }
 }
 for(i=0;i<n;i++){
  printf("%d\n",num[i]);
 }
}
int main()
{
    int i, j, n, m, c, t;

    scanf("%d",&n);
    for(i = 1; i <= n; i++)
    {
        c = 60;
        scanf("%d",&m);
        for(j = 1; j <= m; j++)
        {
            scanf("%d",&t);
            if(t < c)
                c = (t + 3 > c) ? t : (c - 3);
        }
        printf("%d\n",c);
    }
    return 0;
}
int main()
{
    int n,i,j,t,y;
    int a[20];
    scanf("%d\n",&n);
    for(i=0;i<n;i++)
    {
      y=0;
     scanf("%d",&t);
     if(t==0) y=60;
     for(j=0;j<t;j++)
     scanf("%d",&a[j]);
     for(j=0;j<t;j++)
     {if(3*j+a[j]>60) {y=60-3*j;break;}
     else if(3*j+a[j]>=57) {y=a[j];break;}}
      if(a[t-1]+3*t<60) y=60-3*t;
     printf("%d\n",y);
     }
     return 0;
}