#include #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); int N; cin >> N; vector a(N); rep(i,N) cin >> a[i]; int SUM = accumulate(a.begin(), a.end(), 0); vector D; for(int i = 1; i * i <= SUM; i++) { if(SUM % i == 0) { D.push_back(i); D.push_back(SUM / i); } } auto f = [&](int x) { int cur = 0; rep(i,N) { cur += a[i]; if(cur < x) continue; if(cur == x) { cur = 0; continue; } if(cur > x) return false; } return true; }; sort(D.begin(), D.end()); for(int x : D) if(f(x)) { cout << SUM / x << endl; return 0; } }