#include <bits/stdc++.h>
using namespace std;
long long int arr[100005];
map<long long int, int> m;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%I64d", &arr[i]);
  }
  for (int i = 1; i <= n; i++) {
    arr[i] += arr[i - 1];
    m[arr[i]]++;
  }
  int maxVal = 0;
  for (int i = 1; i <= n; i++) {
    maxVal = max(maxVal, m[arr[i - 1]]);
  }
  printf("%d", n - maxVal);
}
