$N=<>;@D=sort{$a-$b}glob<>;
for$d(@D){
	if($d-$p<$d){
		++$_[24-$d]
	}else{
		++$_[$d]
	}
	$p=$d
}
if($_[0]||$_[24]||grep$_>=2,@_){
	print 0
}else{
	@_=grep$_[$_],1..24;
	$x=12;
	"@_ @{[24+$_[0]]}"=~s/\d+ /$x-=$-=$x-($'-$&)/ger;
	print$x
}
