#include <bits/stdc++.h>
typedef struct List {
  struct List *next;
  long long value;
  int num;
} list;
int main() {
  int i, N;
  long long A[200001] = {};
  scanf("%d", &N);
  for (i = 1; i <= N; i++) scanf("%lld", &(A[i]));
  long long h;
  list *p, data[200001] = {}, *hash[30011] = {&(data[0])};
  for (i = 1; i <= N; i++) {
    data[i].value = data[i - 1].value + A[i];
    for (h = llabs(data[i].value) % 30011, p = hash[h]; p != NULL;
         p = p->next) {
      if (data[i].value == p->value) break;
    }
    if (p != NULL)
      (p->num)++;
    else {
      data[i].next = hash[h];
      data[i].num = 0;
      hash[h] = &(data[i]);
    }
  }
  long long ans = 0;
  for (i = 0; i < 30011; i++) {
    for (p = hash[i]; p != NULL; p = p->next) ans += p->num * (p->num + 1) / 2;
  }
  printf("%lld\n", ans);
  fflush(stdout);
  return 0;
}
