#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 20;
const long long M = 500000 + 20;
long long a[N], sum[N];
map<long long, long long> mp;
int main() {
  long long n;
  scanf("%lld", &n);
  mp[0] = 1;
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    sum[i] = sum[i - 1] + a[i];
    mp[sum[i]]++;
  }
  long long ans = 0;
  for (auto it = mp.begin(); it != mp.end(); it++) {
    long long a = it->first, b = it->second;
    if (b >= 2) ans += b * (b - 1) / 2;
  }
  printf("%lld\n", ans);
  return 0;
}
