#include <stdio.h>

constexpr int kN = int(1E5 + 10), kC = int(1E7 + 10);


int a[kN], n;

bool ok(int x) {
	int now = 0;
	for (int i = 1; i <= n; i++) {
		if (now + a[i] > x) return false;
		else now += a[i];
		if (now == x) now = 0;
	}
	return true;
}



int main() {
	int tot = 0, ans = 1;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	for (int i = 1; i <= n; i++) tot += a[i];
	for (int i = 1; i <= tot; i++) if (tot % i == 0) {
		if (ok(i)) {
			printf("%d\n", tot / i);
			return 0;
		}
	}
}