s=z=0 f={} gets gets.split.map{|a|f[s+=a.to_i]=1} 1.upto(s){|r|s%r<1&&(1..r).all?{|j|f[s/r*j]}&&z=r} p z