<>; $a[$_]++for glob<>; for$i(1..8){ for$j(1..8){ $z+=$a[$i]*$a[$j]*$i**$j; } } print$z;