#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, i, x, sum = 0, k = 0, ans = 999999;
  map<long long int, long long int> d;
  scanf("%lld", &n);
  for (i = 0; i < n; ++i) {
    cin >> x;
    sum += x;
    d[sum]++;
    ans = min(ans, n - d[sum]);
  }
  cout << ans << endl;
  return 0;
}
