gets;a=gets.split.map &:to_i;s=a.sum (1..s**0.5).to_a.map{|i|s%i==0?[i,s/i]:[]}.flatten.sort.each{|i|x=0;a.each{|b|x+=b;x==i&&x=0;x>i&&break};x==0&&p(s/i)&&exit}