#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long arr[200005], brr[200005];
map<long long, long long> sh;
void solve() {
  long long i, j, k, l, r, m, n, a, b, c, d, x, y, z, t;
  cin >> n;
  t = 0;
  long long sum = 0;
  for (i = 0; i < n; i++) {
    cin >> arr[i];
    arr[n + i] = arr[i];
    sum += arr[i];
    brr[i] = sum;
    sh[sum]++;
  }
  l = t;
  long long ans = 1000000000;
  ans = n - sh[0];
  long long cur = 0;
  for (i = 1; i < n; i++) {
    sh[brr[i - 1]]--;
    cur += arr[n + i - 1];
    sh[cur]++;
    ans = min(ans, n - sh[cur]);
  }
  cout << ans << endl;
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long t = 1;
  while (t--) solve();
  return 0;
}
