#include <bits/stdc++.h>
using namespace std;
long long a[100000 + 9], n, sum[100000 + 9], mx;
int main() {
  long long i;
  scanf("%lld", &n);
  for (i = 1; i <= n; i++) scanf("%lld", &a[i]), sum[i] = sum[i - 1] + a[i];
  sort(sum + 1, sum + 1 + n);
  for (i = 1; i <= n; i++)
    mx = max(mx, (long long)(upper_bound(sum + 1, sum + 1 + n, sum[i]) -
                             lower_bound(sum + 1, sum + 1 + n, sum[i])));
  printf("%lld", n - mx);
}
