#include <bits/stdc++.h>
using namespace std;
long long a[100005];
int main() {
  long long s = 0;
  long n;
  cin >> n;
  ++n;
  for (long i = 1; i < n; i++) {
    scanf("%lld", &a[i]);
  }
  for (long i = 2; i < n; i++) {
    a[i] += a[i - 1];
  }
  a[0] = 0;
  sort(a, a + n);
  a[n] = LONG_LONG_MAX;
  for (long i = 1, j = 1; i <= n; i++) {
    if (a[i] == a[i - 1])
      j++;
    else {
      s += j * (long long)(j - 1) / 2;
      j = 1;
    }
  }
  printf("%lld\n", s);
  return 0;
}
