#include <bits/stdc++.h>
using namespace std;
long long a[100100], s[100100];
map<long long, int> mp;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%I64d", &a[i]);
    s[i + 1] = s[i] + a[i];
    mp[s[i + 1]]++;
  }
  int mx = 0;
  for (auto it : mp) {
    mx = max(mx, it.second);
  }
  printf("%d\n", n - mx);
  return 0;
}
