N = int(input()) A = list(map(int, input().split())) # 約数列挙 def make_divisors(n): lower_divisors , upper_divisors = [], [] i = 1 while i*i <= n: if n % i == 0: lower_divisors.append(i) if i != n // i: upper_divisors.append(n//i) i += 1 return lower_divisors + upper_divisors[::-1] def bisec(x): l = 0 r = len(accm) while r - l > 1: m = (l + r) // 2 if accm[m] >= x: r = m else: l = m if accm[r] == x: return True else: return False sm = 0 accm = [0] for i in range(N): accm.append(accm[i] + A[i]) sm += A[i] md = make_divisors(sm) md.pop() ans = 1 for d in md: num = sm // d x = 0 for i in range(1, num): x = d * i if not bisec(x): break else: ans = num break print(ans)