for$m(2..499){map$$_+=$-=($x=${$_+$m})&&$x+1-$$_,grep($m%$_<1,2..$m)<2&&-2e4..-1}print${-<>}||-1