N = int(input()) A = list(map(int, input().split())) def divs(n): i = 1 res = [] while i * i <= n: if n % i == 0: res.append(i) res.append(n // i) i += 1 return res 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) ans = 0 for d in divs(S): if check(S // d): ans = max(ans, d) print(ans)