$M{0}=0; sub F{ my($n,$m)=@_; $M{$n}//=F($m=$%/($%/$n+1|0)|0)+($%%$n+$%%($m+1))*($n-$m)/2|0 } $%=<>; print-F($`-/ /)+F($'),$/for<>