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) exists = np.zeros(S+1, np.bool_) exists[Acum] = 1 for d in div: if np.all(exists[np.arange(d,S,d)]): answer = S // d break print(answer)