#include <bits/stdc++.h>
int n;
long long x, t;
long long a[200000];
long long b[200001];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%lld", a + i);
  for (int i = 0; i < n; i++) b[i + 1] = b[i] + a[i];
  std::sort(b, b + n + 1);
  t = 1;
  for (int i = 0; i < n; i++) {
    if (b[i] != b[i + 1]) {
      x += t * (t - 1) / 2;
      t = 1;
    } else
      t++;
  }
  x += t * (t - 1) / 2;
  printf("%d\n", x);
}
