#include <bits/stdc++.h>
using namespace std;
int main() {
  long long arr[100005];
  map<long long, long long> mop;
  long long n, ans = INT_MAX;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
    arr[i] += arr[i - 1];
    mop[arr[i]]++;
  }
  for (map<long long, long long>::iterator it = mop.begin(); it != mop.end();
       it++) {
    ans = min(ans, n - (it->second));
  }
  cout << ans << endl;
  return 0;
}
