#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-8;
map<long long, int> cont;
long long in[100009];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> in[i];
  }
  int ans = n + 1;
  long long psum = 0;
  for (int i = 0; i < n; i++) {
    psum += in[i];
    cont[psum]++;
    ans = min(ans, n - cont[psum]);
  }
  cout << ans << endl;
  return 0;
}
