#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<long long> a(N);
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
  }
  long long ans = 0ll;
  int ub = 0;
  long long sm = 0ll;
  for (int lb = 0; lb < N; ++lb) {
    while (ub < N) {
      sm += a[ub++];
      if (sm == 0) {
        ans++;
      }
    }
    sm -= a[lb];
    if (ub == N) {
      ub = lb + 1;
      sm = 0ll;
    }
  }
  cout << ans << endl;
  return 0;
}
