#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  long long A[210000], AS[210000];
  scanf("%d", &N);
  for (int i = 0; i < N; i++) scanf("%lld", &A[i]);
  AS[0] = A[0];
  for (int i = 1; i < N; i++) AS[i] = AS[i - 1] + A[i];
  AS[N] = 0;
  sort(AS, AS + N + 1);
  long long c = 0;
  for (int i = 0; i < N; i++) {
    long long n = 1;
    while (AS[i + 1] == AS[i]) {
      i++;
      n++;
    }
    c += n * (n - 1) / 2;
  }
  printf("%lld\n", c);
}
