#include <bits/stdc++.h>
using namespace std;
int N, A[212345];
long long sum[212345];
int main() {
  scanf("%d", &N);
  for (long long i = 0; i < (N); ++i) scanf("%d", &A[i]);
  map<long long, int> m;
  sum[0] = A[0];
  m[0]++;
  m[A[0]]++;
  long long count = 0;
  for (long long i = 0; i < (N); ++i)
    if (i) {
      sum[i] = sum[i - 1] + A[i];
      count += m[sum[i]];
      m[sum[i]]++;
    }
  printf("%lld\n", count);
  return 0;
}
