N = int(input()) a_list = list(map(int, input().split())) a_sum = sum(a_list) a_max = max(a_list) div_list = [] for i in range(1, int(a_sum**0.5) + 1): if a_sum % i == 0: if i >= a_max: div_list.append(i) if i != a_sum // i: if (a_sum // i) >= a_max: div_list.append(a_sum // i) div_list.sort() for div in div_list: end = True count = 0 for a in a_list: count += a if count > div: end = False break elif count == div: count = 0 if end: print(a_sum // div) break