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