#include using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) begin(v),end(v) template inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; } using ll = long long; using pii = pair; constexpr ll INF = 1ll<<30; constexpr ll longINF = 1ll<<60; constexpr ll MOD = 1000000007; constexpr bool debug = false; //---------------------------------// std::vector find_divisor(ll n) { assert(n > 0); std::vector divisor; ll i = 1; for (; i * i <= n; i++) if (n % i == 0) divisor.emplace_back(i); int p = divisor.size() - 1; if (divisor[p] * divisor[p] == n) --p; for (; p >= 0; --p) divisor.emplace_back(n / divisor[p]); return divisor; } int main() { int N; cin >> N; vector A(N); REP(i, N) scanf("%d", &A[i]); const int s = accumulate(ALL(A), 0); for (int d : find_divisor(s)) { int cnt = 0, sum = 0; REP(i, N) { sum += A[i]; if (sum > d) { cnt = -1; break; } if (sum == d) { ++cnt; sum = 0; } } if (sum > 0) cnt = -1; if (cnt == -1) continue; printf("%d\n", cnt); return 0; } }