## https://yukicoder.me/problems/no/944 import math def main(): N = int(input()) A = list(map(int, input().split())) # 解答候補を出す sum_a = sum(A) max_a = max(A) sqrt_sum_a = int(math.sqrt(sum_a)) candidates = [] for p in range(1, sqrt_sum_a + 1): if sum_a % p == 0: q = sum_a // p if q >= max_a: candidates.append(p) if q != p and p >= max_a: candidates.append(q) candidates.sort() # 累積和と array = [-1] * (sum_a + 1) cumsum_a = 0 for i in range(N): cumsum_a += A[i] array[cumsum_a] = i answer = 1 for p in candidates: if p <= 1: continue q = sum_a // p is_ok = True for j in range(p): if array[(j + 1) * q] == -1: is_ok = False break if is_ok: answer = p print(answer) if __name__ == "__main__": main()