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