#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long LINF = 1LL << 62;
int main() {
  int N;
  cin >> N;
  long long a[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  long long ans = 0;
  for (int i = 0; i < N - 1; i++) {
    a[i + 1] += a[i];
  }
  sort(a, a + N);
  long long u = -1;
  for (int i = 0; i < N; i++) {
    if (a[i] != a[i + 1]) {
      u = -1;
    }
    ans += u;
  }
  cout << ans << endl;
  return 0;
}
