N = int(input()) A = list(map(int, input().split())) def divs(n): i = 1 while i * i <= n: if n % i == 0: yield i yield n // i i += 1 def check(x): i = 0 while i < N: s = 0 while i < N and s < x: s += A[i] i += 1 if x != s: return False return True S = sum(A) print(max(d for d in divs(S) if check(S // d)))