#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long partialSum[n + 1];
  partialSum[0] = 0;
  for (int i = 1; i <= n; i++) {
    partialSum[i] = partialSum[i - 1] + a[i - 1];
  }
  map<int, int> m;
  map<int, int>::iterator itr;
  pair<int, int> p;
  for (int i = 0; i <= n; i++) {
    if (m.find(partialSum[i]) == m.end()) {
      m[partialSum[i]] = 1;
    } else {
      itr = m.find(partialSum[i]);
      m[partialSum[i]]++;
    }
  }
  long long ans = 0;
  for (itr = m.begin(); itr != m.end(); itr++) {
    p = *itr;
    if (p.second >= 2) {
      ans += p.second * (p.second - 1) / 2;
    }
  }
  cout << ans << endl;
  return 0;
}
