<>;map{$%=$=if($==++$d[$i=$_])>$%;$=>$d[$i]and$d[$i]=$=while($i+=$_)<=1e6}sort{$a-$b}glob<>;print$%