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