import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np A = np.fromstring(read(), np.int64, sep=' ')[1:] Acum = np.cumsum(A) S = Acum[-1] x = np.arange(1, int(S**.5)+1, dtype=np.int64) div = x[S%x == 0] div = np.union1d(div, S // div) se = set(Acum) for d in div: if set(np.arange(d,S,d)) <= se: answer = S//d break print(answer)