#include <bits/stdc++.h>
using namespace std;
long long a, b[200005];
int main() {
  int n, i, j, t;
  long long sum;
  scanf("%d", &n);
  sum = t = 0;
  for (i = 0; i < n; i++) {
    scanf("%lld", &a);
    sum += a;
    b[i] = sum;
    if (sum == 0) t++;
  }
  sort(b, b + n);
  int q = b[0], p = 0;
  for (i = 1; i < n; i++) {
    if (q == b[i])
      p++;
    else {
      if (p != 0) t += p * (p + 1) / 2;
      p = 0;
      q = b[i];
    }
  }
  if (p != 0) t += p * (p + 1) / 2;
  printf("%d\n", t);
}
