#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int arr[100100];
map<ll, int> cnt;
int main() {
  int n;
  cin >> n;
  int ans = 0;
  long long sum = 0, delay = 0;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
    sum += arr[i];
    cnt[sum]++;
  }
  for (int i = n; i; i--) {
    ans = max(cnt[-delay]--, ans);
    delay += arr[i];
    cnt[arr[i] - delay]++;
  }
  cout << n - ans << endl;
  return 0;
}
