#include <bits/stdc++.h>
template <typename T>
T factorial(T n) {
  assert(n > 0);
  if (n == 1 or n == 0) {
    return 1;
  } else {
    return factorial(n - 1) * n;
  }
}
template <typename T>
T factorial(T n, T minN) {
  assert(n > 0);
  assert(minN > 0);
  if (n == minN) {
    return n;
  } else {
    return factorial(n - 1, minN) * n;
  }
}
template <typename T>
T combination(T n, T r) {
  assert(n > 0);
  assert(r > 0);
  return factorial(n, n - r + 1) / factorial(r);
}
template <typename T>
std::vector<std::pair<T, long long int>> countSortedArr(T *arr,
                                                        const long long int n) {
  std::vector<std::pair<T, long long int>> result;
  T cVal = arr[0];
  long long int cCal = 1;
  for (long long int i = 1; i < n; ++i) {
    if (arr[i] == cVal) {
      cCal++;
    }
    if (arr[i] != cVal or i == n - 1) {
      std::pair<T, long long int> pair = std::make_pair(cVal, cCal);
      result.push_back(pair);
      cVal = arr[i];
      cCal = 1;
    }
  }
  return result;
}
int main() {
  int N;
  long long int *M;
  std::cin >> N;
  M = new long long int[N + 1];
  M[0] = 0;
  for (int i = 0; i < N; ++i) {
    int a;
    std::cin >> a;
    M[i + 1] = M[i] + a;
  }
  std::sort(M, M + (N + 1));
  std::vector<std::pair<long long int, long long int>> countArr =
      countSortedArr(M, N + 1);
  int count = 0;
  for (const std::pair<long long int, long long int> &pair : countArr) {
    if (pair.second > 1) {
      count += combination(pair.second, (long long int)2);
    }
  }
  std::cout << count << std::endl;
  delete[](M);
  return 0;
}
