@b=-<>;$_++for@c[glob<>];$%=3e5;$b[$%]=$b[$%+1]+$c[$%],map$z-=$%*$c[$%]*$b[$_*$%],0..2e5/$%while--$%;print$z