#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;
  set<long long> tmp;
  long long sum = 0;
  vector<long long> v;
  v.resize(n);
  for (int i = 0; i < n; i++) {
    sum += a[i];
    s.insert(sum);
    v[i] = sum;
    if (tmp.find(sum) == tmp.end()) {
      tmp.insert(sum);
    }
  }
  long long res = 0;
  for (auto it = tmp.begin(); it != tmp.end(); it++) {
    int count = s.count(*it);
    res += count * (count - 1) / 2;
  }
  res += s.count(0);
  cout << res << endl;
  return 0;
}
