#include <bits/stdc++.h>
using namespace std;
long long factorial(int n) {
  long long ret = 1;
  for (int i = n; i >= 2; i--) {
    ret *= i;
  }
  return ret;
}
long long comb(int n, int r) {
  if (n >= r) {
    return factorial(n) / (factorial(r) * factorial(n - r));
  } else {
    return 0;
  }
}
int main() {
  int N;
  scanf("%d", &N);
  int A[N];
  for (int i = 0; i < N; i++) {
    scanf("%d", A + i);
  }
  long long S[N + 1];
  S[0] = 0;
  long long s = 0;
  for (int i = 0; i < N; i++) {
    s += A[i];
    S[i + 1] = s;
  }
  sort(S, S + N + 1);
  int count = 0;
  int cs = 0;
  for (int i = 0; i < N; i++) {
    if (S[i] == S[i + 1]) {
      cs++;
    } else {
      if (cs > 0) {
        count += comb(cs + 1, 2);
        cs = 0;
      }
    }
    if (i == N - 1) {
      if (cs > 0) {
        count += comb(cs + 1, 2);
        cs = 0;
      }
    }
  }
  printf("%d\n", count);
  return 0;
}
