def div(n): rlst = [] for i in range(1, int(n ** 0.5) + 1): if n % i == 0: rlst.append(i) if i != n // i: rlst.append(n // i) rlst.sort() return rlst N = int(input()) a = list(map(int, input().split())) totala = sum(a) divlst = div(totala) ruia = [0] * (N + 1) for i in range(N): ruia[i + 1] = a[i] + ruia[i] ans = 0 for i in divlst: tmp = totala // i cnt = 0 for j in ruia[1:]: if j % i == 0: cnt += 1 if tmp == cnt: ans = max(ans, cnt) print(ans)