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