def main(): import sys input = sys.stdin.read().split() N = int(input[0]) a = list(map(int, input[1:N+1])) sum_S = sum(a) def get_divisors(s): divisors = set() for i in range(1, int(s**0.5) + 1): if s % i == 0: divisors.add(i) divisors.add(s // i) return divisors divisors = get_divisors(sum_S) candidates = [d for d in divisors if d <= N] candidates.sort(reverse=True) for d in candidates: t = sum_S // d current_sum = 0 cnt = 0 possible = True for num in a: current_sum += num if current_sum == t: cnt += 1 current_sum = 0 elif current_sum > t: possible = False break if possible and current_sum == 0 and cnt == d: print(d) return print(1) if __name__ == '__main__': main()