/**
 *file:????11-24??
 *author:???
 *date?201011-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 ;
}