import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] arr = new int[n]; int total = 0; for (int i = 0; i < n; i++) { arr[i] = sc.nextInt(); total += arr[i]; } TreeSet set = new TreeSet<>(); for (int i = 2; i <= Math.sqrt(total); i++) { if (total % i == 0) { set.add(total / i); int idx = 0; boolean flag = true; int cur = 0; while (idx < n) { cur += arr[idx]; if (cur > i) { flag = false; break; } else if (cur == i) { cur = 0; } idx++; } if (flag) { System.out.println(total / i); return; } } } for (int x : set) { int idx = 0; boolean flag = true; int cur = 0; while (idx < n) { cur += arr[idx]; if (cur > x) { flag = false; break; } else if (cur == x) { cur = 0; } idx++; } if (flag) { System.out.println(total / x); return; } } System.out.println(1); } }