#include <bits/stdc++.h>
using namespace std;
int main() {
  int n = 0;
  cin >> n;
  vector<long long> a;
  a.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  multiset<long long> s;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    sum += a[i];
    s.insert(sum);
  }
  int res = 0;
  for (auto it = s.begin(); it != s.end(); it++) {
    res += s.count(*it) - 1;
  }
  res /= 2;
  res += s.count(0);
  cout << res << endl;
  return 0;
}
