$n=<>;$_++for@b[glob<>];map{$j=$t=0;$t+=$b[$j]while($j+=$_)<@b;$d[$n-$t]=$_}1..@b;pop@d;print$x+=$-=$_-$x,$/for@d