s,*f=0 `sed 1d`.split.map{f[s+=_1.to_i]=1} p s.downto(1).find{|r|s%r<1&&(1..r).all?{f[s/r*_1]}}