#include <bits/stdc++.h>
using namespace std;
int n, x[100005], ans = 2 * 100005;
map<long long, int> d;
int main() {
  scanf("%d", &n);
  long long prev = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x[i]);
    prev = prev + x[i];
    d[prev]++;
    ans = min(ans, n - d[prev]);
  }
  printf("%d", ans);
}
