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