#include <bits/stdc++.h>
using namespace std;
long long n, a[100001], s, ans;
map<long long, long long> mm;
int main(void) {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    s += a[i];
    mm[s]++;
    ans = max(mm[s], ans);
  }
  cout << n - ans;
}
