#include <bits/stdc++.h>
using namespace std;
map<long long int, int> mp;
int main() {
  int n;
  scanf("d", &n);
  long long int ret = 0, sum = 0;
  mp[0]++;
  for (int i = 0; i < n; i++) {
    long long int a;
    scanf("%lld", &a);
    sum += a;
    ret += mp[sum];
    mp[sum]++;
  }
  printf("%lld\n", ret);
  return 0;
}
