def make_divisors(n): divisors = [] #必要に応じてsetにしても良いかも i = 1 while i ** 2 <= n: if n % i == 0: divisors.append(i) if i ** 2 != n: divisors.append(n//i) i += 1 divisors.sort() return divisors from itertools import accumulate N = int(input()) A = [0] + list(map(int,input().split())) A = list(accumulate(A)) SA = set(A) suma = A[-1] PL = make_divisors(suma) for p in PL: for i in range(1,suma//p): if i * p not in SA: break else: print(suma//p) exit()