#include <bits/stdc++.h>
using namespace std;
map<int, long long> s;
map<int, long long>::iterator it;
int main() {
  int n;
  long long sum = 0, a;
  scanf("%d", &n);
  s[0]++;
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a);
    sum += a;
    s[sum]++;
  }
  long long ans = 0;
  for (it = s.begin(); it != s.end(); it++) {
    if (it->second > 1) {
      ans += (it->second) * (it->second - 1) / 2;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
