#include <bits/stdc++.h>
int main() {
  long long int n, t, ret;
  std::cin >> n;
  std::vector<long long int> a(n, 0), s(n, 0);
  for (long long int i = 0; i < n; i++) {
    std::cin >> t;
    a[i] = t;
    if (i > 0)
      s[i] = s[i - 1] + t;
    else
      s[i] = t;
  }
  std::sort(s.begin(), s.end());
  t = 0;
  ret = 0;
  for (auto& el : s) {
    if (el == 0)
      ret++;
    else
      break;
  }
  for (long long int i = 0; i < n; i++) {
    if (s[i] != s[t]) {
      auto m = i - t;
      ret += m * (m - 1) / 2;
      t = i;
    }
  }
  auto m = n - t;
  ret += m * (m - 1) / 2;
  std::cout << ret << std::endl;
  return 0;
}
