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