#include <bits/stdc++.h>
const int INF_INT = 0x3f3f3f3f;
const long long INF_LL = 0x7f7f7f7f;
const int MOD = 1e9 + 7;
const double eps = 1e-10;
const double pi = acos(-1);
using namespace std;
int n;
int a[100100];
int main(int argc, char const *argv[]) {
  while (scanf("%d", &n) == 1) {
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    map<long long, int> mp;
    long long sum = 0;
    for (int i = 0; i < n; i++) {
      mp[sum += a[i]]++;
    }
    int ans = n;
    for (map<long long, int>::iterator it = mp.begin(); it != mp.end(); it++) {
      ans = min(ans, n - it->second);
    }
    cout << ans << endl;
  }
  return 0;
}
