($N,$D,$T)=glob<>; @X=sort{$a%$D-$b%$D||$a-$b}map$_+1e9,glob<>; for(@X){ if( defined$p && $_%$D==$p%$D && ($_/$D|0)-$T<=$m ){ $%+=($_/$D|0)+$T-$m }else{ $%+=2*$T+1 } $m=($_/$D|0)+$T; $p=$_ } print$%