#include <bits/stdc++.h>
using namespace std;
uintmax_t combination(unsigned int n, unsigned int r) {
  if (r * 2 > n) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor = 1;
  for (unsigned int i = 1; i <= r; ++i) {
    dividend *= (n - i + 1);
    divisor *= i;
  }
  return dividend / divisor;
}
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  map<int, int> x;
  for (auto i = 0; i < N; ++i) {
    cin >> A[i];
  }
  int count = 0;
  int sum = 0;
  for (auto j = 0; j < N; ++j) {
    sum += A[j];
    x[sum] += 1;
  }
  for (auto iter = x.begin(); iter != x.end(); ++iter) {
    int l = iter->first;
    int r = iter->second;
    if (l == 0) {
      count += combination(r + 1, 2);
    } else if (r > 1) {
      count += combination(r, 2);
    }
  }
  cout << count << endl;
}
