#include using namespace std; typedef long long ll; #define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++) #define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++) #define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--) #define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define sz(x) ((ll)(x).size()) #define len(x) ((ll)(x).length()) #define endl "\n" template vector get_divisor(T n) { vector res; for (long long i = 1; (i * i) <= n; i++) { if (n % i != 0) continue; res.push_back(i); if ((i * i) != n) res.push_back(n / i); } sort(res.begin(), res.end()); return res; } int main() { cin.tie(0); ios::sync_with_stdio(false); // ifstream in("input.txt"); // cin.rdbuf(in.rdbuf()); ll n; cin >> n; vector a(n); rep(i, n) cin >> a[i]; ll sum = accumulate(all(a), 0LL); auto div = get_divisor(sum); ll ans = 1; for(auto &x : div) { ll tmp = 0; bool f = true; rep(i, n) { tmp += a[i]; if (tmp == x) { tmp = 0; } else if (tmp > x) { f = false; break; } } if (f) ans = max(ans, sum / x); } cout << ans << endl; return 0; }