#include <bits/stdc++.h>
using namespace std;
void zero_sum_range() {
  int n;
  vector<long long> a;
  map<long long, long long> m;
  cin >> n;
  for (int i = 0; i < n; i++) {
    long long tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
  long long total = 0;
  m[total]++;
  for (int i = 0; i < n; i++) {
    total += a[i];
    m[total]++;
  }
  int count = 0;
  map<long long, long long>::iterator p = m.begin();
  while (p != m.end()) {
    count += (p->second - 1) * p->second / 2;
    p++;
  }
  cout << count << endl;
}
int main() {
  zero_sum_range();
  return 0;
}
