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