N = int(input()) a = list(map(int,input().split())) def calc(x): count = 0 now = 0 left = 0 while left < N: right = left while right < N and now + a[right] <= x: now += a[right] right += 1 if now < x: return 0 now = 0 count += 1 left = right return count ans = 0 S = sum(a) i = 1 while i * i <= S: if S % i == 0: t = calc(i) if t > ans: ans = t t = calc(S // i) if t > ans: ans = t i += 1 print(ans)