n = int(input()) A = list(map(int, input().split())) se = set() tot = 0 for a in A: tot += a se.add(tot) cand = [] for i in range(1, int(tot ** 0.5 + 1)): if tot % i == 0: cand.append(i) if i != tot // i: cand.append(tot // i) cand.sort() for c in cand: if tot // c > n: continue ok = True for i in range(c, tot + 1, c): if i not in se: ok = False break if ok: print(tot // c) break