#include using namespace std; int N; vector a; bool f(int n) { int cur = a[0]; for (int i = 1; i < N; ++i) { if (cur > n) return false; if (cur == n) cur = 0; cur += a[i]; } if (cur == n) return true; return false; } int main() { scanf("%d", &N); a.resize(N); int sum = 0; for (int i = 0; i < N; ++i) { scanf("%d", &a[i]); sum += a[i]; } int ans = 1; for (int i = 1; i * i <= sum; ++i) { if (sum % i == 0 && sum / i != i) { if (f(i)) ans = max(ans, sum / i); if (f(sum / i)) ans = max(ans, i); } } printf("%d\n", ans); return 0; }