import java.io.InputStream; import java.io.PrintWriter; import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.PriorityQueue; import java.util.Scanner; import java.util.Set; import java.util.Stack; import java.util.TreeMap; import java.util.TreeSet; import static java.util.Comparator.*; public class Main { public static void main(String[] args) { PrintWriter out = new PrintWriter(System.out); Solver solver = new Solver(System.in, out); solver.solve(); out.close(); } } class Solver { Scanner sc; PrintWriter out; public Solver(InputStream in, PrintWriter out) { sc = new Scanner(in); this.out = out; } // ================================================================== public void solve() { int N = Integer.parseInt(sc.next()); int[] A = new int[N]; int total = 0, max = 0; for (int i = 0; i < N; i++) { A[i] = Integer.parseInt(sc.next()); total += A[i]; max = Math.max(max, A[i]); } int sum; boolean f; for (int i = max; i <= total; i++) { if(total % i != 0) continue; sum = 0; f = true; for (int j = 0; j < N; j++) { sum += A[j]; if(sum == i) sum = 0; else if(sum > i) { f = false; break; } } if(f) { out.println(total / i); return; } } } // ================================================================== }