#include <bits/stdc++.h>
using namespace std;
vector<int> A;
vector<int> factorial(100000, 0);
int done = 2;
int res = 0;
int zero = 0;
void fact(int n) {
  while (done <= n) {
    factorial[done] = done * factorial[done - 1];
    done++;
  }
}
int ans() {
  sort(A.begin(), A.end());
  int i = 0;
  while (i < A.size()) {
    int count = 1;
    while (A[i] == A[i + 1]) {
      i++;
      count++;
    }
    if (count >= 2) {
      if (factorial[count] != 0) {
        res += factorial[count] / (factorial[count - 2] * 2);
      } else {
        fact(count);
        res += factorial[count] / (factorial[count - 2] * 2);
      }
    }
    i++;
  }
  return res;
}
int main() {
  factorial[0] = 1;
  factorial[1] = 1;
  int N;
  cin >> N;
  A.clear();
  A.resize(N);
  int temp;
  cin >> temp;
  A[0] = temp;
  for (int i = 1; i < N; i++) {
    cin >> temp;
    A[i] = A[i - 1] + temp;
    if (A[i] == 0) {
      res++;
    }
  }
  cout << ans() << endl;
  return 0;
}
