#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
ll combination(ll n, ll r) {
  if (r * 2 > n) {
    r = n - r;
  }
  double ret = 1.0;
  for (size_t i = 1; i <= r; i++) {
    ret = ret * (n - i + 1) / i;
  }
  return (ll)ret;
}
int main(int argc, char const *argv[]) {
  int n;
  std::cin >> n;
  std::vector<ll> a(n + 1);
  a[0] = 0;
  for (size_t i = 1; i < a.size(); i++) {
    int temp;
    std::cin >> temp;
    a[i] = temp + a[i - 1];
  }
  sort(a.begin(), a.end());
  ull ans = 0;
  int pre = a[0];
  int count = 1;
  for (size_t i = 1; i < a.size(); i++) {
    if (a[i] == pre) {
      count++;
      continue;
    } else {
      if (count != 1) {
        ans += combination(count, 2);
      }
      pre = a[i];
      count = 1;
    }
  }
  std::cout << ans << '\n';
  return 0;
}
