#include using namespace std; using ll = long long; using ul = unsigned long; using ull = unsigned long long; int getFactors(const ll n, set& f) { int res{ 0 }; for (ll i = 1; i * i <= n; ++i) { if (n % i == 0) { f.insert(i); ++res; auto p = f.insert(n / i); if (p.second) ++res; } } return res; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll n; cin >> n; set sum; ll t{ 0 }; ll a; for (int i = 0; i < n; ++i) { cin >> a; t += a; sum.insert(t); } ll res{ 1 }; if (n > 1) { set s; getFactors(t, s); auto it = s.end(); s.erase(--it); for (auto it = s.begin(); it != s.end(); ++it) { bool f{ true }; for (int j = 1; j <= t / *it; ++j) { if (!sum.count(*it * j)) { f = false; break; } } if (f) { res = t / *it; break; } } } cout << res << "\n"; return 0; }