#include <bits/stdc++.h>
int main() {
  int n;
  std::cin >> n;
  std::map<int, int> sums;
  sums[0] = 1;
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    int a;
    std::cin >> a;
    sum += a;
    ++sums[sum];
  }
  int cnt = 0;
  for (auto v : sums) {
    cnt += v.second * (v.second - 1) / 2;
  }
  std::cout << cnt << std::endl;
}
