#include <bits/stdc++.h>
long long combination(int a, int b) {
  long long ret = 1;
  for (int i = 0; i < b; i++) {
    ret *= a - i;
  }
  for (int i = 0; i < b; i++) {
    ret /= b - i;
  }
  return ret;
}
int main(void) {
  int N;
  scanf("%d", &N);
  int Ai[N];
  for (int i = 0; i < N; i++) {
    scanf("%d", &Ai[i]);
  }
  std::vector<int> totals;
  totals.push_back(0);
  int sum = 0;
  for (int i = 0; i < N; i++) {
    sum += Ai[i];
    totals.push_back(sum);
  }
  std::sort(totals.begin(), totals.end());
  totals.push_back(-1);
  long long count = 0;
  int sameCount = 0;
  int before = -1;
  for (int i = 0; i < N + 1; i++) {
    int a = totals[i];
    if (before == a) {
      sameCount++;
    } else {
      count += combination(sameCount, 2);
      before = a;
      sameCount = 1;
    }
  }
  printf("%lld\n", count);
  return 0;
}
