N = gets.to_i A = gets.split.map(&:to_i) a_max = A.max S = Array.new(N + 1, 0) A.each_with_index{|a,i| S[i + 1] = S[i] + a } ans = (1 .. N).reverse_each.find do |n| r,m = S[N].divmod(n) m == 0 && r >= a_max && S.count{|v| v % r == 0 } > n end puts ans