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