use integer;sub f{map{push@{$_+0},"$a[--$|] $'"for@a=/\d+ /g}<>;my$r=1;$r+=$t=!$c[$_]++&&&f,$%+=$t*($N-$t)*/ /*$'*2for@{$_+0};$r}f for$N=<>;print$%