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