#include <bits/stdc++.h>
int N;
int* A;
int* acc;
int getCount(int t) {
  int res = 0;
  for (int i = 0; i < N + 1; i++) {
    if (acc[i] == t) {
      res++;
    }
  }
  if (res == 1) return 0;
  return res * (res - 1) / 2;
}
int main() {
  std::set<int> st;
  scanf("%d\n", &N);
  A = new int[N];
  acc = new int[N + 1];
  for (int i = 0; i < N; i++) {
    scanf("%d", &A[i]);
  }
  acc[0] = 0;
  int tmp = 0;
  for (int i = 0; i < N; i++) {
    tmp += A[i];
    acc[i + 1] = tmp;
  }
  int res = 0;
  for (int i = 0; i < N + 1; i++) {
    if (st.find(acc[i]) == st.end()) {
      st.insert(acc[i]);
      res += getCount(acc[i]);
    }
  }
  printf("%d\n", res);
  return 0;
}
