import java.io.*; import java.util.*; public class Main { static HashSet sums = new HashSet<>(); public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int total = 0; while (n-- > 0) { total += sc.nextInt(); sums.add(total); } int ans = 1; for (int i = 1; i <= Math.sqrt(total); i++) { if (total % i == 0) { if (check(i, total)) { ans = Math.max(i, ans); } if (check(total / i, total)) { ans = Math.max(total / i, ans); } } } System.out.println(ans); } static boolean check(int count, int total) { int num = total / count; for (int i = 1; i <= count; i++) { if (!sums.contains(i * num)) { return false; } } return true; } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }