#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
const int N = 1e5 + 10;
long long a[N];
long long b[N];
map<long long, long long> mp;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    scanf("%lld", &a[i]), b[i] = a[i] + b[i - 1], mp[b[i]]++;
  map<long long, long long>::iterator it = mp.begin();
  long long ans = 0;
  while (it != mp.end()) {
    if (it->first == 0) ans += it->second;
    ans += it->second * (it->second - 1) / 2;
    it++;
  }
  printf("%lld\n", ans);
  return 0;
}
