#include <bits/stdc++.h>
const double EPS = 0.00000001;
const long long mod = 1000000000 + 7;
using namespace std;
long long a[100100], pref[100100];
map<long long, int> mp;
int main() {
  ios::sync_with_stdio(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  pref[0] = a[0];
  for (int i = 1; i < n; i++) pref[i] = pref[i - 1] + a[i];
  for (int i = 0; i < n; i++) mp[pref[i]]++;
  int mx = 0;
  for (auto x : mp) {
    mx = max(mx, x.second);
  }
  cout << n - mx << endl;
  int ______________;
  cin >> ______________;
  return 0;
}
