#include <bits/stdc++.h>
using namespace std;
long long n;
long long a[200007];
long long b[200007];
int main() {
  scanf("%lld", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    b[i] = b[i - 1] + a[i];
  }
  long long sum = 0;
  sort(b, b + n + 1);
  int lst = -((int)0x7f7f7f7f), cnt = 0;
  for (int i = 0; i <= n; i++) {
    if (lst != b[i]) {
      lst = b[i];
      cnt = 0;
    } else
      cnt++;
    sum += cnt;
  }
  printf("%lld\n", sum);
  return 0;
}
