#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const long long mod = 1000000;
const int prime = 999983;
const int INF = 0x3f3f3f3f;
const int INFF = 1e9;
const double pi = 3.141592653589793;
const double inf = 1e18;
const double eps = 1e-10;
inline int read_int() {
  int ret = 0;
  char tmp;
  while (!isdigit(tmp = getchar()))
    ;
  do {
    ret = (ret << 3) + (ret << 1) + tmp - '0';
  } while (isdigit(tmp = getchar()));
  return ret;
}
long long s[100010];
map<long long, int> mp;
int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int ta;
    scanf("%d", &ta);
    s[i] = s[i - 1] + ta;
    mp[s[i]]++;
    if (ans < mp[s[i]]) ans = mp[s[i]];
  }
  cout << n - ans << endl;
}
